This commit is contained in:
mez 2025-04-27 12:21:32 +01:00
parent a0cb496ffc
commit 3ccea1ac3c
34 changed files with 7 additions and 2844 deletions

15
.gitignore vendored
View file

@ -1,9 +1,8 @@
__pycache__/ __pycache__/
build.sh build/games/*
gamebuild/* !build/games/*.css
!gamebuild/*.css !build/games/*.png
!gamebuild/*.png secrets.py
placebuild/* build/places/*
!placebuild/.gitkeep !build/places/.gitkeep
recordbuild/index.html placelist.py
variables.py

View file

@ -1,67 +0,0 @@
#+TITLE: Trackers
* About
The scripts in this repository build static webpages based on information from two sources:
- a structured set of =.org= files;
- APIs of selected third-party websites (so far: Discogs).
These pages can be used as a replacement for third-party services e.g. Backloggery.
* Dependencies
- =orgparse= (install via pip)
- =python3=
- =rclone= (for syncing to the server)
- =geopy= if you are tracking places visited (install via pip)
- =python3-discogs-client= if you are displaying a record collection (install via pip)
* General setup
** Structure of the .org files
See =demo.org= for an example.
** Setting the variables
Copy =variables-template.py= to =variables.py= and edit:
- =orgpath=: absolute path to the root directory in which =.org= files are stored, including trailing slash
- =localpath=: absolute path to this directory, including trailing slash
- =domain=: =https://yourdomain.tld= without trailing slash
- =rclonesiteroot=: path =rclone= uses to access your webserver
* Tracking games with a backloggery clone
** Setup
*** Fonts
Upload the fonts Lato, Titillium Web, and Material Icons to the directory =/fonts= on your server (I recommend [[https://gwfh.mranftl.com/fonts][google-webfonts-helper]]). Check the filenames are consistent with those in =gamebuild/backloggery.css=. Alternatively, you can load the fonts remotely and adjust the page head HTML generated by =gameskel.py=.
*** Setting the variables
In =variables.py=, edit:
- =trackgames=: set to =True=
- =gameserverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =endlessgames=: a list of “endless” games in the format =title (console)=
- =description=: content for the “about” section (can include HTML tags)
- =gamestartyear=: year from which to begin tracking (an integer)
- =gamehue=: theme colour expressed as a hue from 0 to 360
- =consoles=: add or remove consoles following the format provided (=.png= images must be added to the build directory with a filename corresponding with the value of ="img"= for each console)
** Testing
- Run =python3 generategames.py local= to build in =gamebuild=.
* Tracking places visited using Leaflet
** Setup
Upload a CSS file to the server if necessary. Most CSS is set by Leaflet.
*** Setting the variables
In =variables.py=, edit:
- =trackplaces=: set to =True=
- =placeserverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =placestartyear=: year from which to begin tracking (an integer)
- =placecss=: location of the CSS file you wish to apply, relative to the site root
** Testing
- Run =python3 generateplaces.py local= to build in =placebuild=. (This may take some time.)
- Check whether places are displayed accurately in the output file. If not, add regions/countries to disambiguate any incorrectly displayed places to the =disambig= dictionary in =variables.py= (see examples).
* Displaying a record collection (taking data from Discogs)
** Setup
- Upload a CSS file to the server for styling fonts etc; most CSS is set inline.
- Get a Discogs API token [[https://www.discogs.com/settings/developers][here]].
*** Setting the variables
In =variables.py=, edit:
- =trackrecords=: set to =True=
- =recordserverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =recordcss=: location of the CSS file you wish to apply, relative to the site root
- =discogstoken=: the API token you generated
- =discogsuser=: your Discogs username
** Testing
- Run =python3 generaterecords.py local= to build in =recordbuild=.
* First run (or if adding any new trackers)
- Run =python3 init.py= and then =chmod +x build.sh=.
- Create directories on the server corresponding to any =*serverpath= variables you have set.
* Building
- Run =./build.sh= to build and upload to the server.

View file

@ -1,413 +0,0 @@
import os
import cardstring,gamesort,gameskel,variables
from pathlib import Path
from datetime import datetime,timedelta
"""
Generates backlog page
"""
home = str(Path.home())
def backlog(local=False):
# delete existing file
if not os.path.isdir("gamebuild/backlog"):
os.mkdir("gamebuild/backlog")
if os.path.exists("gamebuild/backlog/index.html"):
os.remove("gamebuild/backlog/index.html")
# write header
gameskel.headerwrite("gamebuild/backlog/index.html","backlog",local)
output = "gamebuild/backlog/index.html"
filewrite = open(output, "a")
filewrite.write(" <section>\n <div>\n <h1>Now Playing</h1>\n <div class=\"now-playing\">\n")
playingnow = []
def nowplaying():
for console in gamesort.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(cardstring.playcard(game,local))
else:
filewrite.write(cardstring.playcard(game,local,True))
filewrite.write(" </div>\n")
# BACKLOG BREAKDOWN
filewrite.write(" <h1>Backlog Breakdown</h1>\n <div class=\"backlog-breakdown\">\n <div class=\"backlog-charts\">\n <div class=\"mem-sum\">\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/index.html")
else:
filewrite.write(variables.gameserverpath + "library")
filewrite.write("\"><text x=\"21\" y=\"17.5\" style=\"font-size: 3.5px; opacity: 0.75; text-anchor: middle;\">Total Games</text>\n <text x=\"21\" y=\"27\" style=\"font-size: 10px; text-anchor: middle;\">" + str(len(gamesort.games)) + "</text>\n <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"4\" stroke=\"#000000c0\" fill=\"transparent\">\n </circle>\n")
backlog = gamesort.unfinished(gamesort.games) + gamesort.unplayed(gamesort.games)
takeup = 100
if gamesort.unplayed(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(200, 30%, 30%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.unplayed(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.unfinished(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 38%, 35%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.unfinished(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.beaten(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 0%, 82%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.beaten(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.completed(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(48, 75%, 70%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.completed(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.endless(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(275, 39%, 32%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
yeargames = 0
yearplaying = 0
for game in gamesort.games:
if game["initialdate"].year == int(gamesort.thisyear):
try:
if game["gameplay"]:
if game["id"] not in variables.endlessgames:
yeargames += 1
except:
yeargames += 1
for game in gamesort.games:
try:
if game["beaten"].year == int(gamesort.thisyear):
yeargames -= 1
except:
try:
if game["completed"].year == int(gamesort.thisyear):
yeargames -= 1
except:
pass
filewrite.write(" </a></svg>\n </div>\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/history/index.html")
else:
filewrite.write(variables.gameserverpath + "history")
filewrite.write("\"><text x=\"21\" y=\"17.5\" style=\"font-size: 3.5px; opacity: 0.75; text-anchor: middle;\">" + gamesort.thisyear + " Backlog</text>\n <text x=\"21\" y=\"27\" style=\"font-size: 10px; text-anchor: middle;\">")
if yeargames > 0:
filewrite.write("")
elif yeargames < 0:
filewrite.write("")
filewrite.write(str(abs(yeargames)) + "</text>\n <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"4\" stroke=\"#000000c0\" fill=\"transparent\">\n </circle>\n")
yearbacklog = []
for game in gamesort.games:
try:
if game["completed"].year == int(gamesort.thisyear):
yearbacklog.append(game)
except:
try:
if game["beaten"].year == int(gamesort.thisyear):
yearbacklog.append(game)
except:
if game["initialdate"].year == int(gamesort.thisyear):
yearbacklog.append(game)
yearcompleted = 0
yearbeaten = 0
yearendless = 0
yearunfinished = 0
yeartotal = len(yearbacklog)
if yeartotal > 0:
for game in yearbacklog:
try:
if game["completed"]:
yearcompleted += 1
except:
try:
if game["beaten"]:
yearbeaten += 1
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
yearendless += 1
else:
yearunfinished += 1
except:
pass
yearunplayed = yeartotal - (yearcompleted + yearbeaten + yearunfinished + yearendless)
yeartakeup = 100
if yearunplayed > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(200, 30%, 30%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearunplayed/yeartotal)*100),1)
if yearunfinished > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 38%, 35%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearunfinished/yeartotal)*100),1)
if yearbeaten > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 0%, 82%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearbeaten/yeartotal)*100),1)
if yearcompleted > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(48, 75%, 70%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearcompleted/yeartotal)*100),1)
if yearendless > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(275, 39%, 32%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
filewrite.write(" </a></svg>\n </div>\n </div>\n <div class=\"status-tally\">\n <div class=\"backlog-tally\">\n <div style=\"width: " + str(round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%;\">")
if ((backlog/gamesort.total(gamesort.games))*100) > 50:
filewrite.write("\n <span>Total Backlog · " + str(backlog) + " · " + str(round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%</span>")
filewrite.write("\n </div>\n <div style=\"width: " + str(100 - round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%;\">")
if ((backlog/gamesort.total(gamesort.games))*100) <= 50:
filewrite.write("\n <span>Active Backlog · " + str(backlog) + " · " + str(round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%</span>")
filewrite.write("\n </div>\n </div>\n")
compare = []
compare.append(gamesort.unplayed(gamesort.games))
compare.append(gamesort.unfinished(gamesort.games))
compare.append(gamesort.beaten(gamesort.games))
compare.append(gamesort.completed(gamesort.games))
compare.append(gamesort.endless(gamesort.games))
maxvalue = max(compare)
if gamesort.unplayed(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unplayed")
filewrite.write("\">\n <div>" + str(gamesort.unplayed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("UP.png\">\n </div>\n <div>\n <div class=\"Unplayed\" style=\"width: calc(100% * (" + str(gamesort.unplayed(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.unplayed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unplayed</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unplayed")
filewrite.write("\">\n <div>" + str(gamesort.unplayed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("UP.png\">\n </div>\n <div>\n <div class=\"Unplayed\" style=\"width: calc(100% * (" + str(gamesort.unplayed(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.unplayed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unplayed</div>\n </div>\n </a>\n")
if gamesort.unfinished(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unfinished")
filewrite.write("\">\n <div>" + str(gamesort.unfinished(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("UF.png\">\n </div>\n <div>\n <div class=\"Unfinished\" style=\"width: calc(100% * (" + str(gamesort.unfinished(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.unfinished(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unfinished</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unfinished")
filewrite.write("\">\n <div>" + str(gamesort.unfinished(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("UF.png\">\n </div>\n <div>\n <div class=\"Unfinished\" style=\"width: calc(100% * (" + str(gamesort.unfinished(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.unfinished(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unfinished</div>\n </div>\n </a>\n")
if gamesort.beaten(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-beaten")
filewrite.write("\">\n <div>" + str(gamesort.beaten(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("B.png\">\n </div>\n <div>\n <div class=\"Beaten\" style=\"width: calc(100% * (" + str(gamesort.beaten(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.beaten(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Beaten</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-beaten")
filewrite.write("\">\n <div>" + str(gamesort.beaten(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("B.png\">\n </div>\n <div>\n <div class=\"Beaten\" style=\"width: calc(100% * (" + str(gamesort.beaten(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.beaten(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Beaten</div>\n </div>\n </a>\n")
if gamesort.completed(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-completed")
filewrite.write("\">\n <div>" + str(gamesort.completed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("C.png\">\n </div>\n <div>\n <div class=\"Completed\" style=\"width: calc(100% * (" + str(gamesort.completed(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.completed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Completed</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-completed")
filewrite.write("\">\n <div>" + str(gamesort.completed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("C.png\">\n </div>\n <div>\n <div class=\"Completed\" style=\"width: calc(100% * (" + str(gamesort.completed(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.completed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Completed</div>\n </div>\n </a>\n")
if gamesort.endless(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-endless")
filewrite.write("\">\n <div>" + str(gamesort.endless(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("E.png\">\n </div>\n <div>\n <div class=\"Endless\" style=\"width: calc(100% * (" + str(gamesort.endless(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.endless(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Endless</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-endless")
filewrite.write("\">\n <div>" + str(gamesort.endless(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.gameserverpath)
filewrite.write("E.png\">\n </div>\n <div>\n <div class=\"Endless\" style=\"width: calc(100% * (" + str(gamesort.endless(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.endless(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Endless</div>\n </div>\n </a>\n")
filewrite.write(" </div>\n </div>\n </div>\n")
# PLATFORM SUMMARY
filewrite.write(" <h1>Platform Summary</h1>\n <div class=\"platform-summary\">\n")
listofconsoles = sorted(variables.consoles,key=lambda d: d["name"])
for console in listofconsoles:
consolegames = []
for game in gamesort.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(" <div class=\"platform-card\">\n <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\" class=\"title\">" + console["name"] + "</a>\n <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\"class=\"abbr\">" + console["shortname"] + "</a>\n <div class=\"bars\">\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 variables.endlessgames:
cendless += 1
else:
cunfinished += 1
except:
pass
cunplayed = ctotal - (ccompleted + cbeaten + cunfinished + cendless)
if cunplayed > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-unplayed")
filewrite.write("\" class=\"unplayed\" title=\"Unplayed\" style=\"flex: " + str(cunplayed) + " 1 0%;\">" + str(cunplayed) + "</a>\n")
if cunfinished > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-unfinished")
filewrite.write("\" class=\"unfinished\" title=\"Unfinished\" style=\"flex: " + str(cunfinished) + " 1 0%;\">" + str(cunfinished) + "</a>\n")
if cbeaten > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-beaten")
filewrite.write("\"class=\"beaten\" title=\"Beaten\" style=\"flex: " + str(cbeaten) + " 1 0%;\">" + str(cbeaten) + "</a>\n")
if ccompleted > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-completed")
filewrite.write("\" class=\"completed\" title=\"Completed\" style=\"flex: " + str(ccompleted) + " 1 0%;\">" + str(ccompleted) + "</a>\n")
if cendless > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-endless")
filewrite.write("\" class=\"endless\" title=\"Endless\" style=\"flex: " + str(cendless) + " 1 0%;\">" + str(cendless) + "</a>\n")
filewrite.write(" </div>\n <a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\" class=\"total\">" + str(ctotal) + "\n <span>Total</span>\n </a>\n </div>\n")
filewrite.write(" </div>\n </div>\n </div>\n")
filewrite.close()
gameskel.footerwrite("gamebuild/backlog/index.html")
if __name__ == "__main__":
backlog(True)

View file

@ -1,205 +0,0 @@
import gamesort,variables
from pathlib import Path
from datetime import datetime,timedelta
home = str(Path.home())
def playcard(game,local=False,decay=False):
cardstring = ""
if decay == True:
cardstring += " <details class=\"game-item decay\">\n"
else:
cardstring += " <details class=\"game-item\">\n"
cardstring += " <summary>\n <div class=\"platform\">\n <div>\n"
for console in variables.consoles:
if game["console"] == console["code"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += console["img"] + ".png\" title=\"" + console["name"] + "\" alt=\"" + console["shortname"] + "\" class=\"bw\">\n"
cardstring += " </div>\n </div>\n <div class=\"status\">\n"
try:
if game["completed"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "C.png\" alt=\"C\" title=\"Completed\">\n"
except:
try:
if game["beaten"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "B.png\" alt=\"B\" title=\"Beaten\">\n"
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "E.png\" alt=\"E\" title=\"Endless\">\n"
else:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "UF.png\" alt=\"UF\" title=\"Unfinished\">\n"
except:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "UP.png\" alt=\"UP\" title=\"Unplayed\">\n"
cardstring += " </div>\n <div class=\"text\">\n <div class=\"title\">" + game["name"] + "</div>\n"
try:
if len(game["recent"]) > 1:
cardstring += " <div class=\"markdown\">" + game["recent"] + "</div>\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 += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in variables.endlessgames:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "paused.png\" alt=\"\" title=\"Paused\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.gameserverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
except:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
cardstring += " </summary>\n <div class=\"game-info game-guest\">\n <div class=\"data\">\n <div class=\"box_2\">\n"
try:
if len(game["recent"]) > 1:
cardstring += " <div>\n <label>Notes</label>\n <div class=\"markdown\">" + game["recent"] + "</div>\n </div>\n"
except:
pass
cardstring += " <div class=\"flex\">\n <div>\n <label>Status</label>\n <p>"
try:
if game["completed"]:
cardstring += "Completed"
except:
try:
if game["beaten"]:
cardstring += "Beaten"
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
cardstring += "Endless"
else:
cardstring += "Unfinished"
except:
cardstring += "Unplayed"
cardstring += "</p>\n </div>\n <div>\n <label>Currently</label>\n <p>"
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 variables.endlessgames:
cardstring += "Not playing"
else:
cardstring += "Paused"
else:
cardstring += "Playing"
except:
cardstring += "Not playing"
cardstring += "</p>\n </div>\n </div>\n </div>\n <div class=\"box_1 m-r0\">\n <div>\n <label>Platform</label>\n <p>"
for console in variables.consoles:
if game["console"] == console["code"]:
cardstring += console["name"]
cardstring += "</p>\n </div>\n <div>\n <label>Last Updated</label>\n <p>" + game["lastupdate"].strftime("%Y-%m-%d") + "</p>\n </div>\n </div>\n </div>\n <div class=\"history\">\n <div class=\"box_1\">\n <h2>Milestones</h2>\n <div class=\"list\">\n <div>\n <div>" + game["initialdate"].strftime("%Y-%m-%d") + "</div>\n <div>\n <div class=\"status-dot Added\"></div>Added</div>\n </div>\n"
try:
if game["firstplayed"]:
cardstring += " <div>\n <div>" + game["firstplayed"].strftime("%Y-%m-%d") + "</div>\n <div>\n <div class=\"status-dot "
if game["id"] in variables.endlessgames:
cardstring += "Endless"
else:
cardstring += "Started"
cardstring += "\"></div>Started</div>\n </div>\n"
except:
pass
try:
if game["beaten"]:
cardstring += " <div>\n <div>" + game["beaten"].strftime("%Y-%m-%d") + "</div>\n <div>\n <div class=\"status-dot Beaten\"></div>Beaten</div>\n </div>\n"
except:
pass
try:
if game["completed"]:
cardstring += " <div>\n <div>" + game["completed"].strftime("%Y-%m-%d") + "</div>\n <div>\n <div class=\"status-dot Completed\"></div>Completed</div>\n </div>\n"
except:
pass
cardstring += " </div>\n </div>\n </div>\n </div>\n </details>\n"
return cardstring
if __name__ == "__main__":
playcard(gamesort.games[0],True)

View file

@ -1,18 +0,0 @@
<2024-02-17 Sat>
* note
Files should be stored in a tree and named like so: =YYYY/MM/YYYY-MM-DD.org=.
* games
** acquired
*** demo game 1 (ps2)
** gameplay
*** demo game 2 (pc)
Notes about the games can be stored under each heading.
** beaten
*** demo game 3 (pc)
** completed
*** demo game 4 (nintendo ds)
* places
** visited
*** demo place 1
*** demo place 2 <2024-02-17 Sat>--<2024-02-18 Sun>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -1,60 +0,0 @@
import colorsys
import variables
from pathlib import Path
"""
Generate the skeleton for a games backlog HTML page.
"""
home = str(Path.home())
def headerwrite(output,section,local=False):
header = open(output, "a")
rgb = colorsys.hls_to_rgb((variables.gamehue)/360,0.3,0.45)
hexstring = ""
for element in rgb:
hexstring += str(hex(int(element * 255)))[2:]
header.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--active-base: hsl(" + str(variables.gamehue) + ", 45%, 30%); --active-secondary: hsl(" + str(variables.gamehue) + ", 15%, 30%); --active-accent: hsl(" + str(variables.gamehue) + ", 90%, 70%);\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta name=\"theme-color\" content=\"#" + hexstring + "\">\n <title>Static backlog</title>\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"Static backlog\" href=\"" + variables.gameserverpath + "feed.xml\">\n <link href=\"")
if local:
header.write(variables.localpath + "gamebuild/")
else:
header.write(variables.gameserverpath)
header.write("backloggery.css\" rel=\"stylesheet\">\n </head>\n <body>\n <div id=\"app\">\n <div class=\"profile\">\n <aside>\n <div>\n <div id=\"about_note\">\n <h2>About</h2>\n <div class=\"markdown\"><p>" + variables.gamedescription + "</p></div>\n </div>\n </div>\n </aside>\n <main>\n <section>\n <div class=\"tabs\">\n")
header.write(" <a href=\"")
if section == "backlog":
header.write("\" class=\"router-link-exact-active router-link-active\" aria-current=\"page")
else:
if local:
header.write(variables.localpath + "gamebuild/backlog/index.html")
else:
header.write(variables.gameserverpath + "backlog")
header.write("\">Backlog</a>\n <a ")
if section == "library":
header.write("class=\"router-link-exact-active router-link-active\" aria-current=\"page\" href=\"")
else:
if section == "sublibrary":
header.write("class=\"router-link-active\" aria-current=\"page\" ")
header.write("href=\"")
if local:
header.write(variables.localpath + "gamebuild/library/index.html")
else:
header.write(variables.gameserverpath + "library")
header.write("\">Library</a>\n <a href=\"")
if section == "history":
header.write("\" class=\"router-link-exact-active router-link-active\" aria-current=\"page")
else:
if local:
header.write(variables.localpath + "gamebuild/history/index.html")
else:
header.write(variables.gameserverpath + "history")
header.write("\">History</a>\n </div>\n")
header.close()
def footerwrite(output):
footer = open(output, "a")
footer.write(" </section>\n </main>\n </div>\n </div>\n </body>\n</html>\n")
footer.close()
if __name__ == "__main__":
headerwrite("gamebuild/backlog/index.html","backlog",True)
footerwrite("test.html")

View file

@ -1,161 +0,0 @@
import orgparse,os,re,variables
from pathlib import Path
from datetime import datetime
"""
Load in the list of games from a set of .org files.
"""
thisyear = datetime.now().strftime("%Y")
year = variables.gamestartyear - 1
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 = variables.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
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 == "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
games = sorted(games,key=lambda d: d["lastupdate"])
consolelists = []
for console in variables.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 variables.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 variables.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)
if __name__ == "__main__":
print(endless(games))

View file

@ -1,26 +0,0 @@
import sys,variables
try:
if sys.argv[1] == "local":
local = True
else:
local = False
except:
local = False
if variables.trackgames == True:
import backlog
import library
import sublibrary
import history
if __name__ == "__main__":
if local == True:
backlog.backlog(True)
library.library(True)
sublibrary.sublibrary(True)
history.history(True)
else:
backlog.backlog()
library.library()
sublibrary.sublibrary()
history.history()

View file

@ -1,121 +0,0 @@
import orgparse,os,re,sys,variables
import time
from datetime import datetime
from geopy.geocoders import Nominatim
try:
if sys.argv[1] == "local":
local = True
else:
local = False
except:
local = False
if variables.trackplaces == True:
thisyear = datetime.now().strftime("%Y")
year = variables.placestartyear
concernedfiles = []
geo = Nominatim(user_agent="python3")
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 = variables.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 = []
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 + ", " + variables.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"])
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:
print("Fetching " + place["name"])
place["lat"] = None
while place["lat"] == None:
try:
place["lat"] = geo.geocode(place["lookup"]).latitude
except:
time.sleep(3)
continue
place["long"] = None
while place["long"] == None:
try:
place["long"] = geo.geocode(place["lookup"]).longitude
except:
time.sleep(3)
continue
alllats = []
alllongs = []
for place in theplaces:
if place["lat"] != 0:
alllats.append(place["lat"])
if place["long"] != 0:
alllongs.append(place["long"])
avglat = (max(alllats) + min(alllats))/2
avglong = (max(alllongs) + min(alllongs))/2
writefile = open("placebuild/index.html","w")
writefile.write("<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <base target=\"_top\">\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> \n <title>Map</title>\n <link rel=\"stylesheet\" href=\"")
if local:
writefile.write(variables.domain)
writefile.write(variables.placecss + "\">\n <link rel=\"stylesheet\" href=\"https://unpkg.com/leaflet@1.9.4/dist/leaflet.css\" integrity=\"sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=\" crossorigin=\"\"/>\n <script src=\"https://unpkg.com/leaflet@1.9.4/dist/leaflet.js\" integrity=\"sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=\" crossorigin=\"\"></script>\n <style>\n #map {\n width: 90vw;\n height: 90vh;\n margin: auto;\n }\n </style>\n </head>\n <body>\n <div id=\"map\" style=\"width: 90vw; height: 90vh;\"></div>\n <script>\n const map = L.map('map').fitBounds([[" + str(min(alllats)) + ", " + str(min(alllongs)) + "],[" + str(max(alllats)) + ", " + str(max(alllongs)) + "]]);\n const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {\n attribution: '&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'\n }).addTo(map);\n")
for place in theplaces:
saniname = re.sub(" ","",(re.sub("","",(re.sub("-","",place["name"])))))
writefile.write(" const " + saniname + " = L.marker([" + str(place["lat"]) + ", " + str(place["long"]) + "]).addTo(map).bindTooltip('<h2>" + place["name"] + "</h2><ul>")
for date in place["dates"]:
writefile.write("<li><code>" + date + "</code></li>")
writefile.write("</ul>');\n")
writefile.write(" </script>\n </body>\n</html>")

View file

@ -1,88 +0,0 @@
import discogs_client,re,time,variables
d = discogs_client.Client("Python/1.0",user_token=variables.discogstoken)
user = d.user(variables.discogsuser)
try:
if sys.argv[1] == "local":
local = True
else:
local = False
except:
local = False
if variables.trackrecords == True:
records = []
thenumber = 1
maxno = len(user.collection_folders[0].releases)
def typography(thestring):
return re.sub(" / ","/",re.sub(" \(.*\)","",re.sub(" - "," ",re.sub(" "," ",re.sub("\.\.\.","",re.sub("'","",re.sub(" = .*","",thestring)))))))
print("Fetching records from Discogs")
for item in user.collection_folders[0].releases:
print("Fetching " + str(thenumber) + " of " + str(maxno))
theitem = {}
theitem["artist"] = typography(item.release.artists[0].name)
theitem["title"] = typography(item.release.title)
try:
if "LP" in item.release.formats[0]["descriptions"] or "12\"" in item.release.formats[0]["descriptions"]:
theitem["format"] = "large"
else:
theitem["format"] = "small"
except:
theitem["format"] = "small"
try:
theitem["img"] = item.release.images[0]["uri"]
except:
pass
records.append(theitem)
thenumber += 1
time.sleep(1) # only allowed 1 request per second
records = sorted(records, key=lambda d: d["title"])
records = sorted(records, key=lambda d: d["artist"])
smalls = []
larges = []
for record in records:
if record["format"] == "large":
larges.append(record)
else:
smalls.append(record)
def recordwrite(record):
recordstring = " <div class=\"container " + record["format"] + "\">\n <img src=\""
try:
recordstring += record["img"]
except:
if record["format"] == "large":
if local:
recordstring += variables.domain
recordstring += variables.recordserverpath + "large.png"
elif record["format"] == "small":
if local:
recordstring += variables.domain
recordstring += variables.recordserverpath + "small.png"
recordstring += "\">\n <div>\n <p>" + record["artist"] + "<br>•<br>" + record["title"] + "</p>\n </div>\n </div>\n"
return recordstring
writefile = open("recordbuild/index.html","w")
writefile.write("<!DOCTYPE html>\n<html>\n <head>\n <link rel=\"stylesheet\" href=\"")
if local:
writefile.write(variables.domain)
writefile.write(variables.recordcss + "\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>Record collection</title>\n <style>\n main {\n display: flex;\n gap: 10px;\n flex-wrap: wrap;\n justify-content: space-evenly;\n }\n .container {\n position: relative;\n display: flex;\n justify-content: center;\n }\n .container.small {\n width: 180px;\n min-width: 180px;\n }\n .container.large {\n width: 300px;\n min-width: 300px;\n }\n .container img {\n display: block;\n width: 100%;\n height: auto;\n margin: auto;\n }\n .container div {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n height: 100%;\n width: 100%;\n opacity: 0;\n transition: .5s ease;\n background-color: rgba(0,0,0,0.5);\n overflow: auto;\n }\n .container:hover div {\n opacity: 1;\n }\n .container div p {\n color: white;\n width: 100%;\n margin: 0;\n position: absolute;\n top: 50%;\n left: 50%;\n -webkit-transform: translate(-50%, -50%);\n -ms-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n text-align: center;\n text-transform: lowercase;\n }\n </style>\n </head>\n <body>\n <h1>Record collection</h1>\n <main>\n")
for record in smalls:
writefile.write(recordwrite(record))
for record in larges:
writefile.write(recordwrite(record))
writefile.write(" </main>\n <p>Generic disc icons by <a href=\"https://www.flaticon.com/free-icon/cd_5344201\">popo2021</a> and <a href=\"https://www.flaticon.com/free-icon/disc_5613845\">Dinosoft Labs</a> on Flaticon.<p>\n </body>\n</html>\n")
writefile.close()

View file

@ -1,168 +0,0 @@
import os
import gamesort,gameskel,variables
from datetime import datetime,timedelta
"""
Generates history page and RSS feed
"""
def history(local=False):
# delete existing files
if not os.path.isdir("gamebuild/history"):
os.mkdir("gamebuild/history")
if os.path.exists("gamebuild/history/index.html"):
os.remove("gamebuild/history/index.html")
if os.path.exists("gamebuild/feed.xml"):
os.remove("gamebuild/feed.xml")
# write header
gameskel.headerwrite("gamebuild/history/index.html","history",local)
output = "gamebuild/history/index.html"
filewrite = open(output, "a")
filewrite.write(" <section class=\"history\">\n <div class=\"list\">\n")
feedwrite = open("gamebuild/feed.xml", "a")
feedwrite.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n <channel>\n <atom:link href=\"" + variables.domain + variables.gameserverpath + "feed.xml\" rel=\"self\" type=\"application/rss+xml\" />\n <title>Static backlog</title>\n <link>" + variables.domain + variables.gameserverpath + "backlog</link>\n <description>Feed for gaming updates</description>\n <language>en-gb</language>")
theyear = int(gamesort.thisyear)
while theyear >= variables.gamestartyear:
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 game in gamesort.games:
if game["initialdate"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Added"})
try:
if game["firstplayed"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"})
except:
pass
try:
if game["beaten"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Beat"})
except:
pass
try:
if game["completed"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Completed"})
except:
pass
eachdate -= timedelta(days=1)
checkdate = enddate
for event in yearlist:
filewrite.write(" <div>\n")
if checkdate != event["date"]:
filewrite.write(" <h2>" + event["date"].strftime("%Y-%m-%d") + "</h2>\n")
filewrite.write(" <div>\n <div> " + event["action"] + "\n <div class=\"status-dot ")
if event["action"] == "Started":
fullpath = str(event["name"] + " (" + event["console"] + ")")
if fullpath in variables.endlessgames:
filewrite.write("Endless")
else:
filewrite.write("Started")
else:
filewrite.write(event["action"])
filewrite.write("\"></div>\n </div>\n <div> " + event["name"] + "\n <span>(" + event["console"] + ")</span>\n </div>\n </div>\n </div>\n")
feedwrite.write(" <item>\n <title>" + event["action"] + " " + event["name"] + " (" + event["console"] + ")</title>\n <pubDate>" + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 GMT</pubDate>\n <link>" + variables.domain + variables.gameserverpath + "history</link>\n <guid isPermaLink=\"false\">" + event["action"] + "-" + event["name"].replace(" ","-") + "-" + event["console"] + "</guid>\n <description>" + event["action"] + " " + event["name"] + " (" + event["console"] + ")</description>\n </item>\n")
checkdate = event["date"]
theyear -= 1
feedwrite.write(" </channel>\n</rss>")
feedwrite.close()
filewrite.write(" </div>\n")
theyear = int(gamesort.thisyear)
filewrite.write(" <div class=\"side box_1\">\n")
while theyear > 2016:
yeargames = 0
yearplaying = 0
for game in gamesort.games:
if game["initialdate"].year == theyear:
try:
if game["gameplay"]:
if game["id"] not in variables.endlessgames:
yeargames += 1
except:
yeargames += 1
for game in gamesort.games:
try:
if game["beaten"].year == theyear:
yeargames -= 1
except:
try:
if game["completed"].year == theyear:
yeargames -= 1
except:
pass
yearbacklog = []
for game in gamesort.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(" <div class=\"year-tally")
if theyear == int(gamesort.thisyear):
filewrite.write(" active")
filewrite.write("\">\n <h2> " + str(theyear) + " Summary\n <span>Backlog ")
if yeargames > 0:
filewrite.write("" + str(yeargames))
elif yeargames == 0:
filewrite.write(" 0")
elif yeargames < 0:
filewrite.write("" + str(yeargames * -1))
filewrite.write("</span></h2>\n <div>\n <div>Added</div>\n <div>" + str(yearadded) + "</div>\n <div>\n <div class=\"unplayed\" style=\"width: calc(95% * (" + str(yearadded) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n <div>\n <div>Started</div>\n <div>" + str(yearstarted) + "</div>\n <div>\n <div class=\"unfinished\" style=\"width: calc(95% * (" + str(yearstarted) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n <div>\n <div>Beat</div>\n <div>" + str(yearbeaten) + "</div>\n <div>\n <div class=\"beaten\" style=\"width: calc(95% * (" + str(yearbeaten) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n <div>\n <div>Completed</div>\n <div>" + str(yearcompleted) + "</div>\n <div>\n <div class=\"completed\" style=\"width: calc(95% * (" + str(yearcompleted) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n </div>\n")
theyear -= 1
filewrite.write(" </div>\n </section>\n")
filewrite.close()
gameskel.footerwrite("gamebuild/history/index.html")
if __name__ == "__main__":
history(True)

16
init.py
View file

@ -1,16 +0,0 @@
import variables
script = open("build.sh", "w")
script.write("#!/usr/bin/env bash\n")
if variables.trackgames == True:
script.write("python3 generategames.py\nrclone copy gamebuild " + variables.rclonesiteroot + variables.gameserverpath + " -P\n")
if variables.trackplaces == True:
script.write("python3 generateplaces.py\nrclone copy placebuild " + variables.rclonesiteroot + variables.placeserverpath + " -P\n")
if variables.trackrecords == True:
script.write("python3 generaterecords.py\nrclone copy recordbuild " + variables.rclonesiteroot + variables.recordserverpath + " -P\n")
script.close()

View file

@ -1,65 +0,0 @@
import os
import cardstring,gamesort,gameskel,variables
"""
Generates library page
"""
def library(local=False):
# delete existing file
if not os.path.isdir("gamebuild/library"):
os.mkdir("gamebuild/library")
if os.path.exists("gamebuild/library/index.html"):
os.remove("gamebuild/library/index.html")
# write header
gameskel.headerwrite("gamebuild/library/index.html","library",local)
output = "gamebuild/library/index.html"
filewrite = open(output, "a")
filewrite.write(" <section id=\"library-top\" class=\"library\">\n <div>\n <div class=\"unibar\">\n <div>\n <span>Total Found</span> " + str(gamesort.total(gamesort.games)) + "\n </div>\n")
if gamesort.unplayed(gamesort.games) > 0:
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unplayed")
filewrite.write("\">" + str(gamesort.unplayed(gamesort.games)) + "</a></div>\n")
if gamesort.unfinished(gamesort.games) > 0:
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unfinished")
filewrite.write("\">" + str(gamesort.unfinished(gamesort.games)) + "</a></div>\n")
if gamesort.beaten(gamesort.games) > 0:
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-beaten")
filewrite.write("\">" + str(gamesort.beaten(gamesort.games)) + "</a></div>\n")
if gamesort.completed(gamesort.games) > 0:
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-completed")
filewrite.write("\">" + str(gamesort.completed(gamesort.games)) + "</a></div>\n")
if gamesort.endless(gamesort.games) > 0:
filewrite.write(" <div class=\"endless\" style=\"flex: " + str(gamesort.endless(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-endless")
filewrite.write("\">" + str(gamesort.endless(gamesort.games)) + "</a></div>\n")
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(gamesort.games,key=lambda d: d["id"])
for game in newgames:
filewrite.write(cardstring.playcard(game,local))
filewrite.close()
gameskel.footerwrite("gamebuild/library/index.html")
if __name__ == "__main__":
library(True)

View file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View file

@ -1,176 +0,0 @@
import os
import cardstring,gamesort,gameskel,variables
from pathlib import Path
"""
Generates sublibrary pages
"""
home = str(Path.home())
def sublibrary(local=False):
statuses = ["all","completed","beaten","unfinished","endless","unplayed"]
consoleextra = [{"shortname":"all"}]
consolesplus = variables.consoles + consoleextra
for console in consolesplus:
gameslist = []
for game in gamesort.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 variables.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 variables.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("gamebuild/library/" + console["shortname"].lower() + "-" + status):
if len(filterlist) > 0:
os.mkdir("gamebuild/library/" + console["shortname"].lower() + "-" + status)
if os.path.exists("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html"):
os.remove("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html")
# write header
if len(filterlist) > 0:
gameskel.headerwrite(("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html"),"sublibrary",local)
output = "gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html"
filewrite = open(output, "a")
filewrite.write(" <section id=\"library-top\" class=\"library\">\n <div>\n <div class=\"filters\">\n <div>Filtered by\n")
if console["shortname"] != "all":
filewrite.write(" <span class=\"item\"><a href=\"")
if status == "all":
if local:
filewrite.write(variables.localpath + "gamebuild/library/index.html")
else:
filewrite.write(variables.gameserverpath + "library")
else:
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-" + status + "/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-" + status)
filewrite.write("\">1 Platform<span class=\"filter_clear\">x</span></a></span>\n")
if status != "all":
filewrite.write(" <span class=\"item\"><a href=\"")
if console["shortname"] == "all":
if local:
filewrite.write(variables.localpath + "gamebuild/library/index.html")
else:
filewrite.write(variables.gameserverpath + "library")
else:
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\">1 Status<span class=\"filter_clear\">x</span></a></span>\n")
filewrite.write(" </div>\n</div> <div class=\"unibar\">\n <div>\n <span>Total Found</span> " + str(gamesort.total(filterlist)) + "\n </div>\n")
if gamesort.unplayed(filterlist) > 0:
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-unplayed")
filewrite.write("\">" + str(gamesort.unplayed(filterlist)) + "</a></div>\n")
if gamesort.unfinished(filterlist) > 0:
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-unfinished")
filewrite.write("\">" + str(gamesort.unfinished(filterlist)) + "</a></div>\n")
if gamesort.beaten(filterlist) > 0:
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-beaten")
filewrite.write("\">" + str(gamesort.beaten(filterlist)) + "</a></div>\n")
if gamesort.completed(filterlist) > 0:
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-completed")
filewrite.write("\">" + str(gamesort.completed(filterlist)) + "</a></div>\n")
if gamesort.endless(filterlist) > 0:
filewrite.write(" <div class=\"endless\" style=\"flex: " + str(gamesort.endless(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-endless")
filewrite.write("\">" + str(gamesort.endless(filterlist)) + "</a></div>\n")
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(filterlist,key=lambda d: d["id"])
for game in newgames:
filewrite.write(cardstring.playcard(game,local))
filewrite.close()
gameskel.footerwrite("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html")
if __name__ == "__main__":
sublibrary(True)

View file

@ -1,64 +0,0 @@
"""
User-defined variables live here.
"""
orgpath = ""
localpath = ""
domain = ""
rclonesiteroot = ""
"""
Games
"""
trackgames = False
gameserverpath = ""
endlessgames = []
gamedescription = ""
gamestartyear = 0
gamehue = 0
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"}]
"""
Places
"""
trackplaces = False
placeserverpath = ""
placestartyear = 0
placecss = ""
# disambig = {"london":"england","belfast":"northern ireland"}
"""
Records
"""
trackrecords = False
recordserverpath = ""
recordcss = ""
discogstoken = ""
discogsuser = ""