diff --git a/.gitignore b/.gitignore
index 2d18ad1..a6d395c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,5 +4,6 @@ build/games/*
!build/games/*.png
secrets.py
build/places/*
-!build/places/.gitkeep
-placelist.py
\ No newline at end of file
+placelist.py
+build/books/*
+build/films/*
\ No newline at end of file
diff --git a/build/places/.gitkeep b/build/places/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/generate.py b/generate.py
index 06e34bb..59a91a7 100644
--- a/generate.py
+++ b/generate.py
@@ -30,6 +30,11 @@ while year < int(thisyear) + 1:
places = []
placenames = []
+books = []
+bookids = []
+
+films = []
+
games = []
gamenames = []
holding = []
@@ -102,9 +107,79 @@ for file in concernedfiles:
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:
+ 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:
+ 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:
+ 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"]))
@@ -927,7 +1002,7 @@ def history():
else:
filewrite.write(event["action"])
filewrite.write("\">\n \n
" + event["name"] + "\n (" + event["console"] + ")\n
\n \n \n")
- 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["console"] + "\n " + event["action"] + " " + event["name"] + " (" + event["console"] + ")\n
\n")
+ 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
@@ -1028,3 +1103,74 @@ def history():
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()