610 lines
34 KiB
Python
610 lines
34 KiB
Python
import datetime,os,random
|
|
from importlib import import_module
|
|
import fandomsedit
|
|
|
|
def stringno(theno):
|
|
if theno < 10:
|
|
return "00" + str(theno)
|
|
elif theno < 100:
|
|
return "0" + str(theno)
|
|
else:
|
|
return str(theno)
|
|
|
|
yearslist = []
|
|
fandomslist = ["Crossovers"]
|
|
|
|
ficcount = 999
|
|
ficlist = []
|
|
while ficcount > 0:
|
|
ficcount -= 1
|
|
ficcountstring = stringno(ficcount)
|
|
if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"):
|
|
ficfile = "files.originalsmeta." + ficcountstring
|
|
fileread = import_module(ficfile)
|
|
try:
|
|
if fileread.revealdate <= datetime.datetime.now():
|
|
goahead = True
|
|
else:
|
|
goahead = False
|
|
except:
|
|
goahead = True
|
|
if goahead == True:
|
|
for datewords in fileread.datewords:
|
|
yearslist.append(datewords["date"].year)
|
|
for fandom in fileread.fandom:
|
|
if fandom in fandomsedit.render:
|
|
fandomslist.append(fandomsedit.render[fandom])
|
|
else:
|
|
fandomslist.append(fandom)
|
|
|
|
fandomslist = sorted(list(dict.fromkeys(fandomslist)),key=str.casefold)
|
|
yearslist = sorted(list(dict.fromkeys(yearslist)))
|
|
|
|
full = []
|
|
|
|
for year in yearslist:
|
|
yeardict = {}
|
|
yeardict["year"] = year
|
|
yeardict["janfics"] = []
|
|
yeardict["janwords"] = 0
|
|
yeardict["febfics"] = []
|
|
yeardict["febwords"] = 0
|
|
yeardict["marfics"] = []
|
|
yeardict["marwords"] = 0
|
|
yeardict["aprfics"] = []
|
|
yeardict["aprwords"] = 0
|
|
yeardict["mayfics"] = []
|
|
yeardict["maywords"] = 0
|
|
yeardict["junfics"] = []
|
|
yeardict["junwords"] = 0
|
|
yeardict["julfics"] = []
|
|
yeardict["julwords"] = 0
|
|
yeardict["augfics"] = []
|
|
yeardict["augwords"] = 0
|
|
yeardict["sepfics"] = []
|
|
yeardict["sepwords"] = 0
|
|
yeardict["octfics"] = []
|
|
yeardict["octwords"] = 0
|
|
yeardict["novfics"] = []
|
|
yeardict["novwords"] = 0
|
|
yeardict["decfics"] = []
|
|
yeardict["decwords"] = 0
|
|
yeardict["unpromptedfics"] = []
|
|
yeardict["unpromptedwords"] = 0
|
|
yeardict["challengefics"] = []
|
|
yeardict["challengewords"] = 0
|
|
yeardict["promptfics"] = []
|
|
yeardict["promptwords"] = 0
|
|
yeardict["exchangefics"] = []
|
|
yeardict["exchangewords"] = 0
|
|
yeardict["fandoms"] = []
|
|
for fandom in fandomslist:
|
|
fandomdict = {}
|
|
fandomdict["name"] = fandom
|
|
fandomdict["fics"] = []
|
|
fandomdict["words"] = 0
|
|
yeardict["fandoms"].append(fandomdict)
|
|
full.append(yeardict)
|
|
|
|
ficcount = 999
|
|
ficlist = []
|
|
while ficcount > 0:
|
|
ficcount -= 1
|
|
ficcountstring = stringno(ficcount)
|
|
if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"):
|
|
ficfile = "files.originalsmeta." + ficcountstring
|
|
fileread = import_module(ficfile)
|
|
try:
|
|
if fileread.revealdate <= datetime.datetime.now():
|
|
goahead = True
|
|
else:
|
|
goahead = False
|
|
except:
|
|
goahead = True
|
|
if goahead == True:
|
|
if len(fileread.fandom) > 1:
|
|
ficfandom = "Crossovers"
|
|
elif fileread.fandom[0] in fandomsedit.render:
|
|
ficfandom = fandomsedit.render[fileread.fandom[0]]
|
|
else:
|
|
ficfandom = fileread.fandom[0]
|
|
try:
|
|
if fileread.event == "ao3exchange":
|
|
ficevent = "exchange"
|
|
else:
|
|
ficevent = fileread.event
|
|
except:
|
|
ficevent = None
|
|
for figure in fileread.datewords:
|
|
for theyear in yearslist:
|
|
if figure["date"].year == theyear:
|
|
for yearstats in full:
|
|
if yearstats["year"] == theyear:
|
|
if ficevent == "exchange":
|
|
yearstats["exchangefics"].append(ficcount)
|
|
yearstats["exchangewords"] += figure["words"]
|
|
elif ficevent == "challenge":
|
|
yearstats["challengefics"].append(ficcount)
|
|
yearstats["challengewords"] += figure["words"]
|
|
elif ficevent == "prompt":
|
|
yearstats["promptfics"].append(ficcount)
|
|
yearstats["promptwords"] += figure["words"]
|
|
elif ficevent == None:
|
|
yearstats["unpromptedfics"].append(ficcount)
|
|
yearstats["unpromptedwords"] += figure["words"]
|
|
if figure["date"].month == 1:
|
|
yearstats["janfics"].append(ficcount)
|
|
yearstats["janwords"] += figure["words"]
|
|
elif figure["date"].month == 2:
|
|
yearstats["febfics"].append(ficcount)
|
|
yearstats["febwords"] += figure["words"]
|
|
elif figure["date"].month == 3:
|
|
yearstats["marfics"].append(ficcount)
|
|
yearstats["marwords"] += figure["words"]
|
|
elif figure["date"].month == 4:
|
|
yearstats["aprfics"].append(ficcount)
|
|
yearstats["aprwords"] += figure["words"]
|
|
elif figure["date"].month == 5:
|
|
yearstats["mayfics"].append(ficcount)
|
|
yearstats["maywords"] += figure["words"]
|
|
elif figure["date"].month == 6:
|
|
yearstats["junfics"].append(ficcount)
|
|
yearstats["junwords"] += figure["words"]
|
|
elif figure["date"].month == 7:
|
|
yearstats["julfics"].append(ficcount)
|
|
yearstats["julwords"] += figure["words"]
|
|
elif figure["date"].month == 8:
|
|
yearstats["augfics"].append(ficcount)
|
|
yearstats["augwords"] += figure["words"]
|
|
elif figure["date"].month == 9:
|
|
yearstats["sepfics"].append(ficcount)
|
|
yearstats["sepwords"] += figure["words"]
|
|
if figure["date"].month == 10:
|
|
yearstats["octfics"].append(ficcount)
|
|
yearstats["octwords"] += figure["words"]
|
|
elif figure["date"].month == 11:
|
|
yearstats["novfics"].append(ficcount)
|
|
yearstats["novwords"] += figure["words"]
|
|
elif figure["date"].month == 12:
|
|
yearstats["decfics"].append(ficcount)
|
|
yearstats["decwords"] += figure["words"]
|
|
for thefandom in fandomslist:
|
|
if ficfandom == thefandom:
|
|
for fandomdict in yearstats["fandoms"]:
|
|
if fandomdict["name"] == ficfandom:
|
|
fandomdict["fics"].append(ficcount)
|
|
fandomdict["words"] += figure["words"]
|
|
try:
|
|
transtarget = fileread.translation
|
|
except:
|
|
transtarget = None
|
|
if transtarget:
|
|
transfile = "files.translationsmeta." + stringno(transtarget)
|
|
transread = import_module(transfile)
|
|
for transfigure in transread.datewords:
|
|
for theyear in yearslist:
|
|
if transfigure["date"].year == theyear:
|
|
for yearstats in full:
|
|
if yearstats["year"] == theyear:
|
|
if ficevent == "exchange":
|
|
yearstats["exchangefics"].append(transtarget)
|
|
yearstats["exchangewords"] += transfigure["words"]
|
|
elif ficevent == "challenge":
|
|
yearstats["challengefics"].append(transtarget)
|
|
yearstats["challengewords"] += transfigure["words"]
|
|
elif ficevent == "prompt":
|
|
yearstats["promptfics"].append(transtarget)
|
|
yearstats["promptwords"] += transfigure["words"]
|
|
elif ficevent == None:
|
|
yearstats["unpromptedfics"].append(transtarget)
|
|
yearstats["unpromptedwords"] += transfigure["words"]
|
|
if transfigure["date"].month == 1:
|
|
yearstats["janfics"].append(transtarget)
|
|
yearstats["janwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 2:
|
|
yearstats["febfics"].append(transtarget)
|
|
yearstats["febwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 3:
|
|
yearstats["marfics"].append(transtarget)
|
|
yearstats["marwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 4:
|
|
yearstats["aprfics"].append(transtarget)
|
|
yearstats["aprwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 5:
|
|
yearstats["mayfics"].append(transtarget)
|
|
yearstats["maywords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 6:
|
|
yearstats["junfics"].append(transtarget)
|
|
yearstats["junwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 7:
|
|
yearstats["julfics"].append(transtarget)
|
|
yearstats["julwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 8:
|
|
yearstats["augfics"].append(transtarget)
|
|
yearstats["augwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 9:
|
|
yearstats["sepfics"].append(transtarget)
|
|
yearstats["sepwords"] += transfigure["words"]
|
|
if transfigure["date"].month == 10:
|
|
yearstats["octfics"].append(transtarget)
|
|
yearstats["octwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 11:
|
|
yearstats["novfics"].append(transtarget)
|
|
yearstats["novwords"] += transfigure["words"]
|
|
elif transfigure["date"].month == 12:
|
|
yearstats["decfics"].append(transtarget)
|
|
yearstats["decwords"] += transfigure["words"]
|
|
for thefandom in fandomslist:
|
|
if ficfandom == thefandom:
|
|
for fandomdict in yearstats["fandoms"]:
|
|
if fandomdict["name"] == ficfandom:
|
|
fandomdict["fics"].append(transtarget)
|
|
fandomdict["words"] += transfigure["words"]
|
|
|
|
if not os.path.isdir("build/stats"):
|
|
os.mkdir("build/stats")
|
|
statspage = open("build/stats/index.html", "w")
|
|
statspage.write("<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>praze • Fanfiction</title>\n <meta property=\"og:title\" content=\"praze • Fanfiction\">\n <meta property=\"og:type\" content=\"website\">\n <meta property=\"og:image\" content=\"https://tre.praze.net/ab.png\">\n <meta property=\"og:url\" content=\"https://tre.praze.net/fic/stats\">\n <meta name=\"description\" property=\"og:description\" content=\"Fanfiction on tre.praze.net\">\n <meta property=\"og:locale\" content=\"en_GB\">\n <meta property=\"og:site_name\" content=\"tre.praze.net\">\n <meta name=\"fediverse:creator\" content=\"@tre@praze.net\">\n <link rel=\"webmention\" href=\"https://webmention.io/tre.praze.net/webmention\">\n <link rel=\"stylesheet\" href=\"/new.css\">\n <link rel=\"stylesheet\" href=\"/fic/fic.css\">\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/charts.css/dist/charts.min.css\">\n <link rel=\"me\" href=\"https://kes.praze.net/@tre\">\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"tre.praze.net\" href=\"/feed.xml\">\n <meta name=\"theme-color\" content=\"#f2f2f2\" />\n </head>\n <body>\n <nav>\n <input type=\"checkbox\" id=\"toggle\" name=\"toggle\">\n <label class=\"toggle-btn\" for=\"toggle\">Menu</label>\n <ul>\n <li>Fundamentals\n <ul>\n <li><a href=\"/\">Home</a></li>\n <li><a href=\"/about\">About + listings</a></li>\n <li><a href=\"/follow\">Follow</a></li>\n <li><a href=\"/feed.xml\">Changelog</a> <a href=\"/feed.xml\"><span class=\"rss\"></span></a></li>\n <li><a href=\"/sitemap.xml\">Sitemap</a></li>\n <li><a href=\"/siteroll\">Siteroll</a></li>\n </ul>\n </li>\n <li>Projects\n <ul>\n <li>Fanfiction <a href=\"/fic/feed.xml\"><span class=\"rss\"></span></a></li>\n <li><a href=\"/music\">Music</a></li>\n <li><a href=\"/notes\">Journal</a></li>\n <li><a href=\"/trackers\">Trackers</a></li>\n <li><a href=\"https://git.praze.net/tre\" target=\"_blank\">Code</a> <a href=\"https://git.praze.net/tre.rss\"><span class=\"rss\"></span></a></li>\n <li><a href=\"https://img.praze.net\" target=\"_blank\">Photos</a> <a href=\"https://img.praze.net/feed.php\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n <li>Fan content\n <ul>\n <li><a href=\"/ffx\">FFX</a></li>\n <li><a href=\"/xvi\">FF16</a></li>\n <li><a href=\"https://morgan.praze.net\" target=\"_blank\">Dermot Morgan</a> <a href=\"https://morgan.praze.net/feed.xml\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n <li>Misc.\n <ul>\n <li><a href=\"https://tcg.praze.net\" target=\"_blank\">TCG</a></li>\n <li><a href=\"https://links.praze.net\" target=\"_blank\">Bookmarks</a> <a href=\"https://links.praze.net/feed/rss\"><span class=\"rss\"></span></a></li>\n <li><a href=\"https://kes.praze.net/@tre\" target=\"_blank\">Fediverse</a> <a href=\"https://kes.praze.net/@tre/feed.rss\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n </ul>\n </nav>\n <div>\n <main>\n<section>\n<h1>Fic stats</h1>\n")
|
|
|
|
totalfics = []
|
|
totalwords = 0
|
|
for yearstats in full:
|
|
for fic in yearstats["janfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["febfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["marfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["aprfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["mayfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["junfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["julfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["augfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["sepfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["octfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["novfics"]:
|
|
totalfics.append(fic)
|
|
for fic in yearstats["decfics"]:
|
|
totalfics.append(fic)
|
|
totalwords += yearstats["janwords"]
|
|
totalwords += yearstats["febwords"]
|
|
totalwords += yearstats["marwords"]
|
|
totalwords += yearstats["aprwords"]
|
|
totalwords += yearstats["maywords"]
|
|
totalwords += yearstats["junwords"]
|
|
totalwords += yearstats["julwords"]
|
|
totalwords += yearstats["augwords"]
|
|
totalwords += yearstats["sepwords"]
|
|
totalwords += yearstats["octwords"]
|
|
totalwords += yearstats["novwords"]
|
|
totalwords += yearstats["decwords"]
|
|
totalfics = sorted(list(dict.fromkeys(totalfics)))
|
|
statspage.write("<ul>\n<li>Total fics: " + str(f"{len(totalfics):,}") + "</li>\n<li>Total words: " + str(f"{totalwords:,}") + "</li>\n</ul>")
|
|
|
|
yearsum = []
|
|
for yearstats in full:
|
|
yeardict = {}
|
|
yearfics = []
|
|
for fic in yearstats["janfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["febfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["marfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["aprfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["mayfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["junfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["julfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["augfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["sepfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["octfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["novfics"]:
|
|
yearfics.append(fic)
|
|
for fic in yearstats["decfics"]:
|
|
yearfics.append(fic)
|
|
yearfics = sorted(list(dict.fromkeys(yearfics)))
|
|
yearwords = 0
|
|
yearwords += yearstats["janwords"]
|
|
yearwords += yearstats["febwords"]
|
|
yearwords += yearstats["marwords"]
|
|
yearwords += yearstats["aprwords"]
|
|
yearwords += yearstats["maywords"]
|
|
yearwords += yearstats["junwords"]
|
|
yearwords += yearstats["julwords"]
|
|
yearwords += yearstats["augwords"]
|
|
yearwords += yearstats["sepwords"]
|
|
yearwords += yearstats["octwords"]
|
|
yearwords += yearstats["novwords"]
|
|
yearwords += yearstats["decwords"]
|
|
yeardict["year"] = yearstats["year"]
|
|
yeardict["fics"] = len(yearfics)
|
|
yeardict["words"] = yearwords
|
|
yearsum.append(yeardict)
|
|
statspage.write("<div class=\"piewrap\"><table class=\"charts-css pie show-heading hide-data\">\n<caption>Words by year</caption>\n")
|
|
startpoint = 0
|
|
for year in yearsum:
|
|
statspage.write("<tr><td style=\"--start:" + str(round(startpoint,5)) + ";--end: " + str(round(year["words"] / totalwords,5) + round(startpoint,5)) + ";\"><span class=\"data\">" + str(year["words"]) + " words</span></td></tr>\n")
|
|
startpoint += round(year["words"] / totalwords,5)
|
|
statspage.write("</table>\n<ul class=\"charts-css legend legend-circle\">\n")
|
|
for year in yearsum:
|
|
statspage.write("<li>" + str(year["year"]) + ": " + str(f'{year["fics"]:,}') + " fic")
|
|
if year["fics"] > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{year["words"]:,}') + " words</li>\n")
|
|
statspage.write("</ul>\n</div>\n")
|
|
|
|
fandomsum = []
|
|
for fandom in fandomslist:
|
|
fandomdict = {}
|
|
fandomfics = []
|
|
fandomwords = 0
|
|
for yearstats in full:
|
|
for thefandom in yearstats["fandoms"]:
|
|
if thefandom["name"] == fandom:
|
|
fandomfics.extend(thefandom["fics"])
|
|
fandomwords += thefandom["words"]
|
|
fandomfics = sorted(list(dict.fromkeys(fandomfics)))
|
|
fandomdict["name"] = fandom
|
|
fandomdict["fics"] = len(fandomfics)
|
|
fandomdict["words"] = fandomwords
|
|
fandomsum.append(fandomdict)
|
|
fandomsum = sorted(fandomsum, key=lambda d: d["words"],reverse=True)
|
|
statspage.write("<div class=\"piewrap\"><table class=\"charts-css pie show-heading hide-data\">\n<caption>Words by fandom</caption>\n")
|
|
startpoint = 0
|
|
for fandom in fandomsum:
|
|
if fandom["words"] > 0:
|
|
statspage.write("<tr><td style=\"--start:" + str(round(startpoint,5)) + ";--end: " + str(round(fandom["words"] / totalwords,5) + round(startpoint,5)) + ";\"><span class=\"data\">" + str(fandom["words"]) + " words</span></td></tr>\n")
|
|
startpoint += round(fandom["words"] / totalwords,5)
|
|
statspage.write("</table>\n<ul class=\"charts-css legend legend-circle\">\n")
|
|
for fandom in fandomsum:
|
|
if fandom["words"] > 0:
|
|
statspage.write("<li>" + str(fandom["name"]) + ": " + str(f'{fandom["fics"]:,}') + " fic")
|
|
if fandom["fics"] > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{fandom["words"]:,}') + " words</li>\n")
|
|
statspage.write("</ul>\n</div>\n")
|
|
|
|
statspage.write("<table class=\"charts-css bar multiple stacked show-heading show-labels hide-data show-primary-axis show-5-secondary-axes data-spacing-3 labels-align-inline-center\">\n<caption>Words by event type per year</caption>\n")
|
|
for yearstats in full:
|
|
if yearstats["challengewords"] + yearstats["exchangewords"] + yearstats["promptwords"] > 0:
|
|
yearwords = 0
|
|
yearwords += yearstats["janwords"]
|
|
yearwords += yearstats["febwords"]
|
|
yearwords += yearstats["marwords"]
|
|
yearwords += yearstats["aprwords"]
|
|
yearwords += yearstats["maywords"]
|
|
yearwords += yearstats["junwords"]
|
|
yearwords += yearstats["julwords"]
|
|
yearwords += yearstats["augwords"]
|
|
yearwords += yearstats["sepwords"]
|
|
yearwords += yearstats["octwords"]
|
|
yearwords += yearstats["novwords"]
|
|
yearwords += yearstats["decwords"]
|
|
statspage.write("<tr>\n<th scope=\"row\">" + str(yearstats["year"]) + "</th>\n")
|
|
challengefics = len(sorted(list(dict.fromkeys(yearstats["challengefics"]))))
|
|
exchangefics = len(sorted(list(dict.fromkeys(yearstats["exchangefics"]))))
|
|
promptfics = len(sorted(list(dict.fromkeys(yearstats["promptfics"]))))
|
|
unpromptedfics = len(sorted(list(dict.fromkeys(yearstats["unpromptedfics"]))))
|
|
statspage.write("<td style=\"--size:" + str(round(yearstats["unpromptedwords"] / yearwords,5)) + ";\"><span class=\"data\">" + str(yearstats["unpromptedwords"]) + " words</span><span class=\"tooltip\">Unprompted: " + str(unpromptedfics) + " fic")
|
|
if unpromptedfics > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{yearstats["unpromptedwords"]:,}') + " words</span></td>\n")
|
|
if challengefics > 0:
|
|
statspage.write("<td style=\"--size:" + str(round(yearstats["challengewords"] / yearwords,5)) + ";\"><span class=\"data\">" + str(yearstats["challengewords"]) + " words</span><span class=\"tooltip\">Challenges: " + str(challengefics) + " fic")
|
|
if challengefics > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{yearstats["challengewords"]:,}') + " words</span></td>\n")
|
|
else:
|
|
statspage.write("<td style=\"--size:0\"></td>\n")
|
|
if exchangefics > 0:
|
|
statspage.write("<td style=\"--size:" + str(round(yearstats["exchangewords"] / yearwords,5)) + ";\"><span class=\"data\">" + str(yearstats["exchangewords"]) + " words</span><span class=\"tooltip\">Exchanges: " + str(exchangefics) + " fic")
|
|
if exchangefics > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{yearstats["exchangewords"]:,}') + " words</span></td>\n")
|
|
else:
|
|
statspage.write("<td style=\"--size:0\"></td>\n")
|
|
if promptfics > 0:
|
|
statspage.write("<td style=\"--size:" + str(round(yearstats["promptwords"] / yearwords,5)) + ";\"><span class=\"data\">" + str(yearstats["promptwords"]) + " words</span><span class=\"tooltip\">Prompt events: " + str(promptfics) + " fic")
|
|
if promptfics > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{yearstats["promptwords"]:,}') + " words</span></td>\n")
|
|
else:
|
|
statspage.write("<td style=\"--size:0\"></td>\n")
|
|
statspage.write("</tr>\n")
|
|
statspage.write("</table>\n")
|
|
|
|
statspage.write("<table class=\"charts-css bar multiple stacked show-heading show-labels hide-data show-primary-axis show-5-secondary-axes data-spacing-3 labels-align-inline-center\">\n<caption>Words by fandom per year</caption>\n")
|
|
for yearstats in full:
|
|
yearwords = 0
|
|
yearwords += yearstats["janwords"]
|
|
yearwords += yearstats["febwords"]
|
|
yearwords += yearstats["marwords"]
|
|
yearwords += yearstats["aprwords"]
|
|
yearwords += yearstats["maywords"]
|
|
yearwords += yearstats["junwords"]
|
|
yearwords += yearstats["julwords"]
|
|
yearwords += yearstats["augwords"]
|
|
yearwords += yearstats["sepwords"]
|
|
yearwords += yearstats["octwords"]
|
|
yearwords += yearstats["novwords"]
|
|
yearwords += yearstats["decwords"]
|
|
yearfandoms = []
|
|
for fandom in fandomslist:
|
|
yearfandomdict = {}
|
|
yearfandomdict["name"] = fandom
|
|
yearfandomdict["fics"] = []
|
|
yearfandomdict["words"] = 0
|
|
for thefandom in yearstats["fandoms"]:
|
|
if thefandom["name"] == fandom:
|
|
yearfandomdict["fics"].extend(thefandom["fics"])
|
|
yearfandomdict["words"] += thefandom["words"]
|
|
yearfandomdict["fics"] = sorted(list(dict.fromkeys(yearfandomdict["fics"])))
|
|
yearfandoms.append(yearfandomdict)
|
|
yearfandoms = sorted(yearfandoms, key=lambda d: d["words"],reverse=True)
|
|
statspage.write("<tr>\n<th scope=\"row\">" + str(yearstats["year"]) + "</th>\n")
|
|
extra = random.randint(0,8)
|
|
while extra > -1:
|
|
statspage.write("<td style=\"--size:0\"></td>")
|
|
extra -= 1
|
|
for fandom in yearfandoms:
|
|
if fandom["words"] > 0:
|
|
statspage.write("<td style=\"--size:" + str(round(fandom["words"] / yearwords,5)) + ";\"><span class=\"data\">" + str(fandom["words"]) + " words</span><span class=\"tooltip\">" + fandom["name"] + ": " + str(len(fandom["fics"])) + " fic")
|
|
if len(fandom["fics"]) > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{fandom["words"]:,}') + " words</span></td>\n")
|
|
statspage.write("</tr>\n")
|
|
statspage.write("</table>\n")
|
|
|
|
allmonths = []
|
|
testyear = full[0]["year"]
|
|
thisyear = datetime.datetime.now().year
|
|
start = False
|
|
while testyear <= thisyear:
|
|
found = False
|
|
for yearstats in full:
|
|
if yearstats["year"] == testyear:
|
|
found = True
|
|
dictone = {}
|
|
if yearstats["janwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictone["month"] = "January " + str(yearstats["year"])
|
|
dictone["fics"] = len(sorted(list(dict.fromkeys(yearstats["janfics"]))))
|
|
dictone["words"] = yearstats["janwords"]
|
|
allmonths.append(dictone)
|
|
dicttwo = {}
|
|
if yearstats["febwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dicttwo["month"] = "February " + str(yearstats["year"])
|
|
dicttwo["fics"] = len(sorted(list(dict.fromkeys(yearstats["febfics"]))))
|
|
dicttwo["words"] = yearstats["febwords"]
|
|
allmonths.append(dicttwo)
|
|
dictthree = {}
|
|
if yearstats["marwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictthree["month"] = "March " + str(yearstats["year"])
|
|
dictthree["fics"] = len(sorted(list(dict.fromkeys(yearstats["marfics"]))))
|
|
dictthree["words"] = yearstats["marwords"]
|
|
allmonths.append(dictthree)
|
|
dictfour = {}
|
|
if yearstats["aprwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictfour["month"] = "April " + str(yearstats["year"])
|
|
dictfour["fics"] = len(sorted(list(dict.fromkeys(yearstats["aprfics"]))))
|
|
dictfour["words"] = yearstats["aprwords"]
|
|
allmonths.append(dictfour)
|
|
dictfive = {}
|
|
if yearstats["maywords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictfive["month"] = "May " + str(yearstats["year"])
|
|
dictfive["fics"] = len(sorted(list(dict.fromkeys(yearstats["mayfics"]))))
|
|
dictfive["words"] = yearstats["maywords"]
|
|
allmonths.append(dictfive)
|
|
dictsix = {}
|
|
if yearstats["junwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictsix["month"] = "June " + str(yearstats["year"])
|
|
dictsix["fics"] = len(sorted(list(dict.fromkeys(yearstats["junfics"]))))
|
|
dictsix["words"] = yearstats["junwords"]
|
|
allmonths.append(dictsix)
|
|
dictseven = {}
|
|
if yearstats["julwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictseven["month"] = "July " + str(yearstats["year"])
|
|
dictseven["fics"] = len(sorted(list(dict.fromkeys(yearstats["julfics"]))))
|
|
dictseven["words"] = yearstats["julwords"]
|
|
allmonths.append(dictseven)
|
|
dicteight = {}
|
|
if yearstats["augwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dicteight["month"] = "August " + str(yearstats["year"])
|
|
dicteight["fics"] = len(sorted(list(dict.fromkeys(yearstats["augfics"]))))
|
|
dicteight["words"] = yearstats["augwords"]
|
|
allmonths.append(dicteight)
|
|
dictnine = {}
|
|
if yearstats["sepwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictnine["month"] = "September " + str(yearstats["year"])
|
|
dictnine["fics"] = len(sorted(list(dict.fromkeys(yearstats["sepfics"]))))
|
|
dictnine["words"] = yearstats["sepwords"]
|
|
allmonths.append(dictnine)
|
|
dictten = {}
|
|
if yearstats["octwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dictten["month"] = "October " + str(yearstats["year"])
|
|
dictten["fics"] = len(sorted(list(dict.fromkeys(yearstats["octfics"]))))
|
|
dictten["words"] = yearstats["octwords"]
|
|
allmonths.append(dictten)
|
|
dicteleven = {}
|
|
if yearstats["novwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dicteleven["month"] = "November " + str(yearstats["year"])
|
|
dicteleven["fics"] = len(sorted(list(dict.fromkeys(yearstats["novfics"]))))
|
|
dicteleven["words"] = yearstats["novwords"]
|
|
allmonths.append(dicteleven)
|
|
dicttwelve = {}
|
|
if yearstats["decwords"] > 0:
|
|
start = True
|
|
if start == True:
|
|
dicttwelve["month"] = "December " + str(yearstats["year"])
|
|
dicttwelve["fics"] = len(sorted(list(dict.fromkeys(yearstats["decfics"]))))
|
|
dicttwelve["words"] = yearstats["decwords"]
|
|
allmonths.append(dicttwelve)
|
|
if found == False:
|
|
allmonths.append({"month":"January " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"February " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"March " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"April " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"May " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"June " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"July " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"August " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"September " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"October " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"November " + str(testyear),"fics":0,"words":0})
|
|
allmonths.append({"month":"December " + str(testyear),"fics":0,"words":0})
|
|
testyear += 1
|
|
checkno = len(allmonths)
|
|
takingoff = True
|
|
while takingoff:
|
|
if allmonths[checkno - 1]["words"] == 0:
|
|
allmonths.remove(allmonths[checkno - 1])
|
|
checkno -= 1
|
|
else:
|
|
takingoff = False
|
|
maxmonthwords = max(allmonths,key=lambda x:x["words"])
|
|
statspage.write("<table class=\"charts-css column show-heading hide-labels hide-data\">\n<caption>Words by month (scrolls sideways)</caption>\n")
|
|
for month in allmonths:
|
|
statspage.write("<tr><th scope=\"row\">" + month["month"] + "</th><td style=\"--size:" + str(round(month["words"] / maxmonthwords["words"],5)) + ";\"><span class=\"data\">" + str(month["words"]) + " words</span><span class=\"tooltip\">" + month["month"] + ": " + str(month["fics"]) + " fic")
|
|
if month["fics"] > 1:
|
|
statspage.write("s")
|
|
statspage.write(", " + str(f'{month["words"]:,}') + " words</span></td></tr>\n")
|
|
statspage.write("</table>\n")
|
|
|
|
|
|
statspage.write("<p><small>With assistance from <a href=\"https://chartscss.org\" target=\"_blank\">Charts.css</a>. Colour scheme inexpertly taken from <a href=\"https://mildliners.rknight.me\" target=\"_blank\">here</a>.</small></p>\n</section>\n </main>\n <footer>\n <ul>\n <li><a href=\"/fic\">back to fic pages</a></li>\n </ul>\n </footer>\n </div>\n <a href=\"/\"><img src=\"/a.png\" style=\"position:fixed;bottom:2px;right:2px;\" title=\"home\"></a>\n </body>\n</html>")
|
|
statspage.close()
|