import placelist,secrets
import colorsys,orgparse,os,re,time
from datetime import datetime,timedelta
thisyear = datetime.now().strftime("%Y")
year = 1993
gamestartyear = 2017
concernedfiles = []
while year < int(thisyear) + 1:
month = 0
while month < 13:
if month < 10:
strmonth = "0" + str(month)
else:
strmonth = str(month)
recdir = str(year) + "/" + strmonth + "/"
fullpath = secrets.orgpath + recdir
if os.path.exists(fullpath):
for file in sorted(os.listdir(fullpath)):
filename = fullpath + str(file)
if filename.endswith(".org"):
concernedfiles.append(filename)
month = month + 1
year = year + 1
places = []
placenames = []
games = []
gamenames = []
holding = []
for file in concernedfiles:
filedate = file[-14:-4]
dateobj = datetime.strptime(filedate,"%Y-%m-%d")
parsefile = orgparse.load(file)
try:
for node in parsefile.children:
if node.heading == "places":
for action in node.children:
if action.heading == "visited":
for place in action.children:
placename = re.sub(" <.*>","",re.sub("<.*> ","",place.heading))
if placename not in placenames:
status = "new"
placenames.append(placename)
else:
status = "existing"
if "<" in place.heading:
dates = re.sub(" [A-Z][a-z][a-z]","",re.sub("--"," to ",re.sub(">","",re.sub("<","",(re.findall("\<.*\>",place.heading)[0])))))
else:
dates = filedate
if status == "new":
try:
lookup = placename + ", " + placelist.disambig[placename]
except:
lookup = placename
thedict = {"name":placename,"dates":[dates],"lookup":lookup}
places.append(thedict)
else:
twodict = {"name":placename,"dates":[dates]}
for origplace in places:
if twodict["name"] == origplace["name"]:
origplace["dates"].extend(twodict["dates"])
if node.heading == "games":
for action in node.children:
for game in action.children:
name = re.sub(" \(.*\)","",game.heading)
if game.heading not in gamenames:
status = "new"
gamenames.append(game.heading)
else:
status = "existing"
console = (re.findall("\(.*\)",game.heading)[0])[1:-1]
if status == "new":
thedict = {"id":game.heading,"name":name,"initialdate":dateobj,"console":console,game.parent.heading:dateobj,"recent":game.body,"lastupdate":dateobj}
if game.parent.heading != "acquired":
thedict.update({"firstplayed":dateobj})
games.append(thedict)
else:
twodict = {"id":game.heading,game.parent.heading:dateobj,"lastupdate":dateobj}
if len(game.body) > 1:
twodict.update({"recent":game.body})
for origgame in games:
if twodict["id"] == origgame["id"]:
try:
if origgame["firstplayed"]:
playedbefore = True
except:
playedbefore = False
if playedbefore == False:
twodict.update({"firstplayed":dateobj})
holding.append(twodict)
for gameupdate in holding:
for origgame in games:
if gameupdate["id"] == origgame["id"]:
gamemerge = {**origgame, **gameupdate}
games.remove(origgame)
games.insert(0,gamemerge)
holding.remove(gameupdate)
except:
pass
for place in places:
place["dates"] = list(dict.fromkeys(place["dates"]))
theplaces = sorted(places,key=lambda d: d["name"])
for place in theplaces:
place["lat"] = False
place["long"] = False
for checkplace in placelist.places:
if place["lookup"] == checkplace["lookup"]:
place["lat"] = checkplace["lat"]
place["long"] = checkplace["long"]
if place["lat"] == False:
print("Warning: " + place["name"] + " should be added to list")
alllats = []
alllongs = []
for place in theplaces:
if place["lat"] != False:
alllats.append(place["lat"])
if place["long"] != False:
alllongs.append(place["long"])
avglat = (max(alllats) + min(alllats))/2
avglong = (max(alllongs) + min(alllongs))/2
writefile = open("build/places/index.html","w")
writefile.write("\n\n
\n \n \n")
games = sorted(games,key=lambda d: d["lastupdate"])
consoles = [{"code":"ps5","name":"PlayStation 5","shortname":"PS5","img":"PS5"},
{"code":"ps2","name":"PlayStation 2","shortname":"PS2","img":"PS2"},
{"code":"ps3","name":"PlayStation 3","shortname":"PS3","img":"PS3"},
{"code":"xbox 360","name":"Xbox 360","shortname":"Xbox360","img":"360"},
{"code":"nintendo ds","name":"Nintendo DS","shortname":"DS","img":"NDS"},
{"code":"nintendo 3ds","name":"Nintendo 3DS","shortname":"3DS","img":"3DS"},
{"code":"nintendo switch","name":"Nintendo Switch","shortname":"Switch","img":"Switch"},
{"code":"pc","name":"PC","shortname":"PC","img":"PC"}]
endlessgames = ["the sims 4 (pc)",
"american truck simulator (pc)",
"civilization iv (pc)",
"final fantasy theatrhythm curtain call (nintendo 3ds)",
"final fantasy xiv (pc)",
"medieval ii: total war (pc)",
"tabletop simulator (pc)",
"train simulator 2020 (pc)"]
consolelists = []
for console in consoles:
consolegames = []
for game in games:
if game["console"] == console["code"]:
consolegames.append(game)
consolelists.append({"code":console["code"],"name":console["name"],"games":consolegames})
def completed(selection):
completed = 0
for game in selection:
try:
if game["completed"]:
completed += 1
except:
pass
return completed
def beaten(selection):
beaten = 0
for game in selection:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
beaten += 1
except:
pass
return beaten
def endless(selection):
endless = 0
for game in selection:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
endless += 1
except:
pass
return(endless)
def unfinished(selection):
unfinished = 0
for game in selection:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] not in endlessgames:
unfinished += 1
except:
pass
return(unfinished)
def total(selection):
return len(selection)
def unplayed(selection):
unplayed = total(selection) - (completed(selection) + beaten(selection) + unfinished(selection) + endless(selection))
return(unplayed)
gamehue = 250
gamedescription = "I nicked this design and method of game tracking from Backloggery. I don’t have full data on when I obtained/started playing some of my games, so some of these statistics are inaccurate.
I classify games by the console I play them on, not the one they were released for, so there are PS4 games under PS5, GBA games under DS, etc.
“Complete” means getting all the achievements if it’s a game/platform that has them; otherwise it means getting in-game 100% completion.
Achievements and playtime are automatically tracked on exophase."
def headerwrite(output,section):
header = open(output, "a")
rgb = colorsys.hls_to_rgb((gamehue)/360,0.3,0.45)
hexstring = ""
for element in rgb:
hexstring += str(hex(int(element * 255)))[2:]
header.write("\n\n
\n"
for console in consoles:
if game["console"] == console["code"]:
cardstring += " \n"
cardstring += "
\n
\n
\n"
try:
if game["completed"]:
cardstring += " \n"
except:
try:
if game["beaten"]:
cardstring += " \n"
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
cardstring += " \n"
else:
cardstring += " \n"
except:
cardstring += " \n"
cardstring += "
\n
\n
" + game["name"] + "
\n"
try:
if len(game["recent"]) > 1:
cardstring += "
" + game["recent"] + "
\n"
except:
pass
try:
if game["gameplay"]:
try:
if game["completed"]:
if game["gameplay"] > game["completed"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "
\n
\n \n
\n"
else:
cardstring += " \n
\n \n
\n"
else:
cardstring += " \n
\n \n
\n"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += " \n
\n \n
\n"
else:
cardstring += " \n
\n \n
\n"
else:
cardstring += " \n
\n \n
\n"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in endlessgames:
cardstring += " \n
\n \n
\n"
else:
cardstring += " \n
\n \n
\n"
else:
cardstring += " \n
\n \n
\n"
except:
cardstring += " \n
\n \n
\n"
cardstring += " \n
\n
\n
\n"
try:
if len(game["recent"]) > 1:
cardstring += "
\n \n
" + game["recent"] + "
\n
\n"
except:
pass
cardstring += "
\n
\n \n
"
try:
if game["completed"]:
cardstring += "Completed"
except:
try:
if game["beaten"]:
cardstring += "Beaten"
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
cardstring += "Endless"
else:
cardstring += "Unfinished"
except:
cardstring += "Unplayed"
cardstring += "
\n
\n
\n \n
"
try:
if game["gameplay"]:
try:
if game["completed"]:
if game["gameplay"] > game["completed"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "Not playing"
else:
cardstring += "Playing"
else:
cardstring += "Not playing"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "Not playing"
else:
cardstring += "Playing"
else:
cardstring += "Not playing"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in endlessgames:
cardstring += "Not playing"
else:
cardstring += "Paused"
else:
cardstring += "Playing"
except:
cardstring += "Not playing"
cardstring += "
\n
\n
\n
\n
\n
\n \n
"
for console in consoles:
if game["console"] == console["code"]:
cardstring += console["name"]
cardstring += "
\n
\n
\n \n
" + game["lastupdate"].strftime("%Y-%m-%d") + "
\n
\n
\n
\n
\n
\n
Milestones
\n
\n
\n
" + game["initialdate"].strftime("%Y-%m-%d") + "
\n
\n Added
\n
\n"
try:
if game["firstplayed"]:
cardstring += "
\n
" + game["firstplayed"].strftime("%Y-%m-%d") + "
\n
\n Started
\n
\n"
except:
pass
try:
if game["beaten"]:
cardstring += "
\n
" + game["beaten"].strftime("%Y-%m-%d") + "
\n
\n Beaten
\n
\n"
except:
pass
try:
if game["completed"]:
cardstring += "
\n
" + game["completed"].strftime("%Y-%m-%d") + "
\n
\n Completed
\n
\n"
except:
pass
cardstring += "
\n
\n
\n
\n \n"
return cardstring
def backlog():
# delete existing file
if not os.path.isdir("build/games/backlog"):
os.mkdir("build/games/backlog")
if os.path.exists("build/games/backlog/index.html"):
os.remove("build/games/backlog/index.html")
# write header
headerwrite("build/games/backlog/index.html","backlog")
output = "build/games/backlog/index.html"
filewrite = open(output, "a")
filewrite.write(" \n
\n
Now Playing
\n
\n")
playingnow = []
def nowplaying():
for console in consolelists:
if len(console["games"]) > 0:
thegame = (console["games"])[-1]
try:
if thegame["gameplay"] > (datetime.now() - timedelta(days=180)):
try:
if thegame["completed"]:
if thegame["completed"] >= thegame["gameplay"]:
playing = False
else:
playing = True
except:
try:
if thegame["beaten"]:
if thegame["beaten"] >= thegame["gameplay"]:
playing = False
else:
playing = True
except:
playing = True
else:
playing = False
except:
playing = False
if playing == True:
playingnow.append(thegame)
nowplaying()
playingnow = sorted(playingnow,key=lambda d: d["lastupdate"],reverse=True)
for game in playingnow:
if playingnow.index(game) == 0:
filewrite.write(playcard(game))
else:
filewrite.write(playcard(game,True))
filewrite.write("
\n")
newgames = sorted(games,key=lambda d: d["id"])
for game in newgames:
filewrite.write(playcard(game))
filewrite.close()
footerwrite("build/games/library/index.html")
if __name__ == "__main__":
library()
def sublibrary():
statuses = ["all","completed","beaten","unfinished","endless","unplayed"]
consoleextra = [{"shortname":"all"}]
consolesplus = consoles + consoleextra
for console in consolesplus:
gameslist = []
for game in games:
if console["shortname"] == "all":
gameslist.append(game)
elif game["console"] == console["code"]:
gameslist.append(game)
for status in statuses:
filterlist = []
if status == "all":
for game in gameslist:
filterlist.append(game)
elif status == "completed":
for game in gameslist:
try:
if game["completed"]:
filterlist.append(game)
except:
pass
elif status == "beaten":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
filterlist.append(game)
except:
pass
elif status == "unfinished":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] not in endlessgames:
filterlist.append(game)
except:
pass
elif status == "endless":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
filterlist.append(game)
except:
pass
elif status == "unplayed":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
pass
except:
filterlist.append(game)
if not os.path.isdir("build/games/library/" + console["shortname"].lower() + "-" + status):
if len(filterlist) > 0:
os.mkdir("build/games/library/" + console["shortname"].lower() + "-" + status)
if os.path.exists("build/games/library/" + console["shortname"].lower() + "-" + status + "/index.html"):
os.remove("build/games/library/" + console["shortname"].lower() + "-" + status + "/index.html")
# write header
if len(filterlist) > 0:
headerwrite(("build/games/library/" + console["shortname"].lower() + "-" + status + "/index.html"),"sublibrary")
output = "build/games/library/" + console["shortname"].lower() + "-" + status + "/index.html"
filewrite = open(output, "a")
filewrite.write(" \n
\n
\n
Filtered by\n")
if console["shortname"] != "all":
filewrite.write(" 1 Platformx\n")
if status != "all":
filewrite.write(" 1 Statusx\n")
filewrite.write("
\n
\n
\n Total Found " + str(total(filterlist)) + "\n
\n")
if unplayed(filterlist) > 0:
filewrite.write("