import datetime,os from importlib import import_module 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 == "FF15": fandomslist.append("Final Fantasy XV") elif fandom == "FF16": fandomslist.append("Final Fantasy XVI") elif fandom == "FF4": fandomslist.append("Final Fantasy IV") elif fandom == "FF6": fandomslist.append("Final Fantasy VI") elif fandom == "FF7": fandomslist.append("Final Fantasy VII") elif fandom == "FF8": fandomslist.append("Final Fantasy VIII") elif fandom == "FF9": fandomslist.append("Final Fantasy IX") elif fandom == "FFX": fandomslist.append("Final Fantasy X") elif fandom == "LOTR": fandomslist.append("Lord Of The Rings") 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] == "FF15": ficfandom = "Final Fantasy XV" elif fileread.fandom[0] == "FF16": ficfandom = "Final Fantasy XVI" elif fileread.fandom[0] == "FF4": ficfandom = "Final Fantasy IV" elif fileread.fandom[0] == "FF6": ficfandom = "Final Fantasy VI" elif fileread.fandom[0] == "FF7": ficfandom = "Final Fantasy VII" elif fileread.fandom[0] == "FF8": ficfandom = "Final Fantasy VIII" elif fileread.fandom[0] == "FF9": ficfandom = "Final Fantasy IX" elif fileread.fandom[0] == "FFX": ficfandom = "Final Fantasy X" elif fileread.fandom[0] == "LOTR": ficfandom = "Lord Of The Rings" 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("\n\n \n \n \n praze • Fanfiction\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
\n

Fic stats

\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("
    \n
  • Total fics: " + str(f"{len(totalfics):,}") + "
  • \n
  • Total words: " + str(f"{totalwords:,}") + "
  • \n
") 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("
\n\n") startpoint = 0 for year in yearsum: statspage.write("\n") startpoint += round(year["words"] / totalwords,5) statspage.write("
Words by year
" + str(year["words"]) + " words
\n
    \n") for year in yearsum: statspage.write("
  • " + str(year["year"]) + ": " + str(f'{year["fics"]:,}') + " fic") if year["fics"] > 1: statspage.write("s") statspage.write(", " + str(f'{year["words"]:,}') + " words
  • \n") statspage.write("
\n
\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("
\n\n") startpoint = 0 for fandom in fandomsum: if fandom["words"] > 0: statspage.write("\n") startpoint += round(fandom["words"] / totalwords,5) statspage.write("
Words by fandom
" + str(fandom["words"]) + " words
\n
    \n") for fandom in fandomsum: if fandom["words"] > 0: statspage.write("
  • " + str(fandom["name"]) + ": " + str(f'{fandom["fics"]:,}') + " fic") if fandom["fics"] > 1: statspage.write("s") statspage.write(", " + str(f'{fandom["words"]:,}') + " words
  • \n") statspage.write("
\n
\n") statspage.write("\n\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("\n\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("\n") if challengefics > 0: statspage.write("\n") if exchangefics > 0: statspage.write("\n") if promptfics > 0: statspage.write("\n") statspage.write("\n") statspage.write("
Words by event type per year
" + str(yearstats["year"]) + "" + str(yearstats["unpromptedwords"]) + " wordsUnprompted: " + str(unpromptedfics) + " fic") if unpromptedfics > 1: statspage.write("s") statspage.write(", " + str(f'{yearstats["unpromptedwords"]:,}') + " words" + str(yearstats["challengewords"]) + " wordsChallenges: " + str(challengefics) + " fic") if challengefics > 1: statspage.write("s") statspage.write(", " + str(f'{yearstats["challengewords"]:,}') + " words" + str(yearstats["exchangewords"]) + " wordsExchanges: " + str(exchangefics) + " fic") if exchangefics > 1: statspage.write("s") statspage.write(", " + str(f'{yearstats["exchangewords"]:,}') + " words" + str(yearstats["promptwords"]) + " wordsPrompt events: " + str(promptfics) + " fic") if promptfics > 1: statspage.write("s") statspage.write(", " + str(f'{yearstats["promptwords"]:,}') + " words
\n") statspage.write("\n\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("\n\n") for fandom in yearfandoms: if fandom["words"] > 0: statspage.write("\n") statspage.write("\n") statspage.write("
Words by fandom per year
" + str(yearstats["year"]) + "" + str(fandom["words"]) + " words" + fandom["name"] + ": " + str(len(fandom["fics"])) + " fic") if len(fandom["fics"]) > 1: statspage.write("s") statspage.write(", " + str(f'{fandom["words"]:,}') + " words
\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("\n\n") for month in allmonths: statspage.write("\n") statspage.write("
Words by month (scrolls sideways)
" + month["month"] + "" + str(month["words"]) + " words" + month["month"] + ": " + str(month["fics"]) + " fic") if month["fics"] > 1: statspage.write("s") statspage.write(", " + str(f'{month["words"]:,}') + " words
\n") statspage.write("

With assistance from Charts.css. Colour scheme inexpertly taken from here.

\n
\n
\n \n
\n \n \n") statspage.close()