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 = [] books = [] bookids = [] films = [] 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) if node.heading == "books": for action in node.children: if action.heading == "read": for book in action.children: if "work" not in book.tags: bookid = re.sub(" and rated .*","",book.heading) if bookid not in bookids: status = "new" bookids.append(bookid) else: status = "existing" readdate = dateobj if status == "new": thedict = {"id":bookid,"readdates":[readdate],"progressdates":[],"obtaineddate":""} books.append(thedict) else: twodict = {"id":bookid,"readdates":[readdate]} for origbook in books: if twodict["id"] == origbook["id"]: origbook["readdates"].extend(twodict["readdates"]) if action.heading == "progress": for book in action.children: if "work" not in book.tags: bookid = book.heading if bookid not in bookids: status = "new" bookids.append(bookid) else: status = "existing" progressdate = dateobj if status == "new": thedict = {"id":bookid,"readdates":[],"progressdates":[progressdate],"obtaineddate":""} books.append(thedict) else: twodict = {"id":bookid,"progressdates":[progressdate]} for origbook in books: if twodict["id"] == origbook["id"]: origbook["progressdates"].extend(twodict["progressdates"]) if action.heading == "obtained": for book in action.children: if "work" not in book.tags: bookid = re.sub(" \(.*\)","",book.heading) if bookid not in bookids: status = "new" bookids.append(bookid) else: status = "existing" obtaineddate = dateobj if status == "new": thedict = {"id":bookid,"readdates":[],"progressdates":[],"obtaineddate":obtaineddate} books.append(thedict) else: twodict = {"id":bookid,"obtaineddate":[obtaineddate]} for origbook in books: if twodict["id"] == origbook["id"]: origbook["obtaineddate"] = twodict["obtaineddate"] if node.heading == "films": for action in node.children: if action.heading == "watched": for film in action.children: filmid = re.sub(" and rated .*","",film.heading) watchdate = dateobj thedict = {"id":filmid,"watched":watchdate} films.append(thedict) except: pass for book in books: try: book["title"] = (re.findall(" /.*/",book["id"])[0])[2:-1] except: book["title"] = (re.findall("/.*/",book["id"])[0])[1:-1] book["author"] = re.sub(" /.*/","",book["id"]) if book["author"][0] == "/": book["author"] = "" 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 \n Map\n \n \n \n \n \n \n
\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 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 \n \n \n Static backlog\n \n \n \n \n

\n
\n \n
\n
\n \n") header.close() def footerwrite(output): footer = open(output, "a") footer.write("
\n
\n
\n
\n \n\n\n") footer.close() def playcard(game,decay=False): cardstring = "" if decay == True: cardstring += "
\n" else: cardstring += "
\n" cardstring += " \n
\n
\n" for console in consoles: if game["console"] == console["code"]: cardstring += " \""\n" cardstring += "
\n
\n
\n" try: if game["completed"]: cardstring += " \"C\"\n" except: try: if game["beaten"]: cardstring += " \"B\"\n" except: try: if game["gameplay"]: if game["id"] in endlessgames: cardstring += " \"E\"\n" else: cardstring += " \"UF\"\n" except: cardstring += " \"UP\"\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"]: try: if game["firstplayed"] != game["beaten"]: cardstring += "
\n
" + game["firstplayed"].strftime("%Y-%m-%d") + "
\n
\n
Started
\n
\n" except: 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") # BACKLOG BREAKDOWN filewrite.write("

Backlog Breakdown

\n
\n
\n
\n \n \n
\n
\n
\n
") if ((backlog/total(games))*100) > 50: filewrite.write("\n Total Backlog · " + str(backlog) + " · " + str(round(((backlog/total(games))*100),1)) + "%") filewrite.write("\n
\n
") if ((backlog/total(games))*100) <= 50: filewrite.write("\n Active Backlog · " + str(backlog) + " · " + str(round(((backlog/total(games))*100),1)) + "%") filewrite.write("\n
\n
\n") compare = [] compare.append(unplayed(games)) compare.append(unfinished(games)) compare.append(beaten(games)) compare.append(completed(games)) compare.append(endless(games)) maxvalue = max(compare) if unplayed(games) / maxvalue > 0.5: filewrite.write(" \n
" + str(unplayed(games)) + "
\n
\n \n
\n
\n
" + str(round(((unplayed(games)/total(games))*100),1)) + "% Unplayed
\n
\n
\n") else: filewrite.write(" \n
" + str(unplayed(games)) + "
\n
\n \n
\n
\n
\n
\n
" + str(round(((unplayed(games)/total(games))*100),1)) + "% Unplayed
\n
\n
\n") if unfinished(games) / maxvalue > 0.5: filewrite.write(" \n
" + str(unfinished(games)) + "
\n
\n \n
\n
\n
" + str(round(((unfinished(games)/total(games))*100),1)) + "% Unfinished
\n
\n
\n") else: filewrite.write(" \n
" + str(unfinished(games)) + "
\n
\n \n
\n
\n
\n
\n
" + str(round(((unfinished(games)/total(games))*100),1)) + "% Unfinished
\n
\n
\n") if beaten(games) / maxvalue > 0.5: filewrite.write(" \n
" + str(beaten(games)) + "
\n
\n \n
\n
\n
" + str(round(((beaten(games)/total(games))*100),1)) + "% Beaten
\n
\n
\n") else: filewrite.write(" \n
" + str(beaten(games)) + "
\n
\n \n
\n
\n
\n
\n
" + str(round(((beaten(games)/total(games))*100),1)) + "% Beaten
\n
\n
\n") if completed(games) / maxvalue > 0.5: filewrite.write(" \n
" + str(completed(games)) + "
\n
\n \n
\n
\n
" + str(round(((completed(games)/total(games))*100),1)) + "% Completed
\n
\n
\n") else: filewrite.write(" \n
" + str(completed(games)) + "
\n
\n \n
\n
\n
\n
\n
" + str(round(((completed(games)/total(games))*100),1)) + "% Completed
\n
\n
\n") if endless(games) / maxvalue > 0.5: filewrite.write(" \n
" + str(endless(games)) + "
\n
\n \n
\n
\n
" + str(round(((endless(games)/total(games))*100),1)) + "% Endless
\n
\n
\n") else: filewrite.write(" \n
" + str(endless(games)) + "
\n
\n \n
\n
\n
\n
\n
" + str(round(((endless(games)/total(games))*100),1)) + "% Endless
\n
\n
\n") filewrite.write("
\n
\n
\n") # PLATFORM SUMMARY filewrite.write("

Platform Summary

\n
\n") listofconsoles = sorted(consoles,key=lambda d: d["name"]) for console in listofconsoles: consolegames = [] for game in games: if game["console"] == console["code"]: consolegames.append(game) ccompleted = 0 cbeaten = 0 cendless = 0 cunfinished = 0 ctotal = len(consolegames) if ctotal > 0: filewrite.write("
\n " + console["name"] + "\n " + console["shortname"] + "\n
\n") for game in consolegames: try: if game["completed"]: ccompleted += 1 except: try: if game["beaten"]: cbeaten += 1 except: try: if game["gameplay"]: if game["id"] in endlessgames: cendless += 1 else: cunfinished += 1 except: pass cunplayed = ctotal - (ccompleted + cbeaten + cunfinished + cendless) if cunplayed > 0: filewrite.write(" " + str(cunplayed) + "\n") if cunfinished > 0: filewrite.write(" " + str(cunfinished) + "\n") if cbeaten > 0: filewrite.write(" " + str(cbeaten) + "\n") if ccompleted > 0: filewrite.write(" " + str(ccompleted) + "\n") if cendless > 0: filewrite.write(" " + str(cendless) + "\n") filewrite.write("
\n " + str(ctotal) + "\n Total\n \n
\n") filewrite.write("
\n
\n \n") filewrite.close() footerwrite("build/games/backlog/index.html") if __name__ == "__main__": backlog() def library(): # delete existing file if not os.path.isdir("build/games/library"): os.mkdir("build/games/library") if os.path.exists("build/games/library/index.html"): os.remove("build/games/library/index.html") # write header headerwrite("build/games/library/index.html","library") output = "build/games/library/index.html" filewrite = open(output, "a") filewrite.write("
\n
\n
\n
\n Total Found " + str(total(games)) + "\n
\n") if unplayed(games) > 0: filewrite.write(" \n") if unfinished(games) > 0: filewrite.write(" \n") if beaten(games) > 0: filewrite.write(" \n") if completed(games) > 0: filewrite.write(" \n") if endless(games) > 0: filewrite.write(" \n") filewrite.write("
\n
\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(" \n") if unfinished(filterlist) > 0: filewrite.write(" \n") if beaten(filterlist) > 0: filewrite.write(" \n") if completed(filterlist) > 0: filewrite.write(" \n") if endless(filterlist) > 0: filewrite.write(" \n") filewrite.write("
\n
\n") newgames = sorted(filterlist,key=lambda d: d["id"]) for game in newgames: filewrite.write(playcard(game)) filewrite.close() footerwrite("build/games/library/" + console["shortname"].lower() + "-" + status + "/index.html") if __name__ == "__main__": sublibrary() def history(): # delete existing files if not os.path.isdir("build/games/history"): os.mkdir("build/games/history") if os.path.exists("build/games/history/index.html"): os.remove("build/games/history/index.html") if os.path.exists("build/games/feed.xml"): os.remove("build/games/feed.xml") # write header headerwrite("build/games/history/index.html","history") output = "build/games/history/index.html" filewrite = open(output, "a") filewrite.write("
\n
\n") feedwrite = open("build/games/feed.xml", "a") feedwrite.write("\n\n \n \n Static backlog\n https://tre.praze.net/trackers/games/backlog\n Feed for gaming updates\n en-gb") theyear = int(thisyear) while theyear >= gamestartyear: histlist = [] feedlist = [] enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d") startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d") eachdate = enddate while eachdate >= startdate: for game in games: try: if game["gameplay"] == eachdate: if game["firstplayed"] != eachdate: feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Playing"}) except: pass try: if game["completed"] == eachdate: histlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Completed"}) feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Completed"}) except: pass try: if game["beaten"] == eachdate: histlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Beat"}) feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Beat"}) except: pass try: if game["firstplayed"] == eachdate: try: if game["beaten"] != eachdate: histlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"}) feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"}) except: try: if game["completed"] != eachdate: histlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"}) feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"}) except: histlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"}) feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"}) except: pass if game["initialdate"] == eachdate: histlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Added"}) feedlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Added"}) eachdate -= timedelta(days=1) checkdate = enddate for event in histlist: filewrite.write("
\n") if checkdate != event["date"]: filewrite.write("

" + event["date"].strftime("%Y-%m-%d") + "

\n") filewrite.write("
\n
" + event["action"] + "\n
\n
\n
" + event["name"] + "\n (" + event["console"] + ")\n
\n
\n
\n") checkdate = event["date"] checkdate = enddate for event in feedlist: feedwrite.write(" \n " + event["action"] + " " + event["name"] + " (" + event["console"] + ")\n " + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 GMT\n https://tre.praze.net/trackers/games/history\n " + event["action"] + "-" + event["name"].replace(" ","-") + "-" + event["date"].strftime("%Y-%m-%d") + "\n " + event["action"] + " " + event["name"] + " (" + event["console"] + ")\n \n") checkdate = event["date"] theyear -= 1 feedwrite.write("
\n
") feedwrite.close() filewrite.write("
\n") theyear = int(thisyear) filewrite.write("
\n") while theyear > 2016: yeargames = 0 yearplaying = 0 for game in games: if game["initialdate"].year == theyear: try: if game["gameplay"]: if game["id"] not in endlessgames: yeargames += 1 except: yeargames += 1 for game in games: try: if game["beaten"].year == theyear: yeargames -= 1 except: try: if game["completed"].year == theyear: yeargames -= 1 except: pass yearbacklog = [] for game in games: try: if game["completed"].year == theyear: yearbacklog.append(game) except: try: if game["beaten"].year == theyear: yearbacklog.append(game) except: if game["initialdate"].year == theyear: yearbacklog.append(game) yearcompleted = 0 yearbeaten = 0 yearstarted = 0 yearadded = 0 yeartotal = len(yearbacklog) if yeartotal > 0: for game in yearbacklog: try: if game["initialdate"].year == theyear: yearadded += 1 except: pass try: if game["firstplayed"].year == theyear: yearstarted += 1 except: pass try: if game["completed"].year == theyear: yearcompleted += 1 except: pass try: if game["beaten"].year == theyear: yearbeaten += 1 except: pass compare = [] compare.append(yearadded) compare.append(yearstarted) compare.append(yearbeaten) compare.append(yearcompleted) maxvalue = max(compare) filewrite.write("
\n

" + str(theyear) + " Summary\n Backlog ") if yeargames > 0: filewrite.write("▲ " + str(yeargames)) elif yeargames == 0: filewrite.write(" 0") elif yeargames < 0: filewrite.write("▼ " + str(yeargames * -1)) filewrite.write("

\n
\n
Added
\n
" + str(yearadded) + "
\n
\n
\n
\n
\n
\n
\n
Started
\n
" + str(yearstarted) + "
\n
\n
\n
\n
\n
\n
\n
Beat
\n
" + str(yearbeaten) + "
\n
\n
\n
\n
\n
\n
\n
Completed
\n
" + str(yearcompleted) + "
\n
\n
\n
\n
\n
\n
\n") theyear -= 1 filewrite.write("
\n
\n") filewrite.close() footerwrite("build/games/history/index.html") if __name__ == "__main__": history() def bookfeed(): if not os.path.isdir("build/books"): os.mkdir("build/books") if os.path.exists("build/books/feed.xml"): os.remove("build/books/feed.xml") feedwrite = open("build/books/feed.xml", "a") feedwrite.write("\n\n \n \n Book log\n https://tre.praze.net\n Feed for book updates\n en-gb") theyear = int(thisyear) while theyear >= 1993: yearlist = [] enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d") startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d") eachdate = enddate while eachdate >= startdate: for book in books: if eachdate in book["readdates"]: yearlist.append({"date":eachdate,"author":book["author"],"title":book["title"].replace("&","&"),"action":"Read"}) try: if book["progressdates"][0] == eachdate: yearlist.append({"date":eachdate,"author":book["author"],"title":book["title"].replace("&","&"),"action":"Reading"}) except: pass if book["obtaineddate"] == eachdate: yearlist.append({"date":eachdate,"author":book["author"],"title":book["title"].replace("&","&"),"action":"Added"}) eachdate -= timedelta(days=1) checkdate = enddate for event in yearlist: feedwrite.write(" \n " + event["action"] + " " + event["title"] + "\n " + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 GMT\n https://tre.praze.net\n " + event["action"] + "-" + event["author"].replace(" ","-") + event["title"].replace(" ","-") + "-" + event["date"].strftime("%Y-%m-%d") + "\n " + event["action"] + " " + event["title"] + " by " + event["author"] + "\n \n") checkdate = event["date"] theyear -= 1 feedwrite.write(" \n") feedwrite.close() if __name__ == "__main__": bookfeed() def filmfeed(): if not os.path.isdir("build/films"): os.mkdir("build/films") if os.path.exists("build/films/feed.xml"): os.remove("build/films/feed.xml") feedwrite = open("build/films/feed.xml", "a") feedwrite.write("\n\n \n \n Film log\n https://tre.praze.net\n Feed of films I have watched\n en-gb") theyear = int(thisyear) while theyear >= 1993: yearlist = [] enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d") startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d") eachdate = enddate while eachdate >= startdate: for film in films: if film["watched"] == eachdate: yearlist.append({"date":eachdate,"id":film["id"].replace("&","&")}) eachdate -= timedelta(days=1) checkdate = enddate for event in yearlist: feedwrite.write(" \n Watched " + event["id"] + "\n " + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 GMT\n https://tre.praze.net\n " + event["id"].replace(" ","-") + "-" + event["date"].strftime("%Y-%m-%d") + "\n Watched " + event["id"] + "\n \n") checkdate = event["date"] theyear -= 1 feedwrite.write(" \n") feedwrite.close() if __name__ == "__main__": filmfeed()