import datetime, os from importlib import import_module import makeheader import headerfooter def fandomlist(local=False): # delete existing file if os.path.exists("build/byfandom/index.html"): os.remove("build/byfandom/index.html") # write header headerfooter.headerwrite("build/byfandom/index.html","Fics by fandom","Fics by fandom","
On this page, you’ll find basically everything I’ve ever written that is a. fanfiction and b. extant, grouped by fandom and then sorted newest to oldest; quality may vary. Some fics, such as things I wrote before 2020, require a username and password to access.
",False,local) # get list of fandoms fandoms = [] ficcount = 500 while ficcount > 0: ficcount -= 1 if ficcount < 10: ficcountstring = "00" + str(ficcount) elif ficcount < 100: ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now(): revealed = False else: revealed = True except: revealed = True if revealed == True: for fandom in fileread.fandom: fandoms.append(fandom) newlist = [] for fandom in fandoms: if fandom not in newlist: newlist.append(fandom) fandomlist = [] for fandom in newlist: if "FF" in fandom: if fandom == "FFX": newfandom = "FF10" elif len(fandom) == 3: newfandom = "FF0" + fandom[-1] else: newfandom = fandom fandomlist.append({"searchname":fandom,"sortname":newfandom.replace("FF","Final Fantasy ").lower(),"displayname":fandom.replace("FF","Final Fantasy ")}) else: fandomlist.append({"searchname":fandom,"sortname":fandom.lower(),"displayname":fandom}) fandomlist = sorted(fandomlist, key=lambda d: d["sortname"]) for fandom in fandomlist: fandomfics = [] fandomwords = 0 sortfics = [] # check which fics are in the fandom ficcount = 500 while ficcount > 0: ficcount -= 1 if ficcount < 10: ficcountstring = "00" + str(ficcount) elif ficcount < 100: ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): countfile = "files.originalsmeta." + ficcountstring fileread = import_module(countfile) try: if fileread.revealdate > datetime.datetime.now(): revealed = False else: revealed = True except: revealed = True if revealed == True: if fandom["searchname"] in fileread.fandom: sumwords = 0 for instalment in fileread.datewords: sumwords = sumwords + instalment["words"] ficdict = {"thefic":ficcount,"thedate":(fileread.datewords[-1])["date"],"totalwords":sumwords} sortfics.append(ficdict) thefics = sorted(sortfics,key=lambda d: d["thedate"],reverse=True) for fic in thefics: fandomfics.append(fic["thefic"]) fandomwords = fandomwords + fic["totalwords"] firstfic = fandomfics[-1] if firstfic < 10: firstficstring = "00" + str(firstfic) elif firstfic < 100: firstficstring = "0" + str(firstfic) else: firstficstring = str(firstfic) firstfile = "files.originalsmeta." + firstficstring firstread = import_module(firstfile) firstyear = (firstread.datewords[0])["date"].year lastfic = fandomfics[0] if lastfic < 10: lastficstring = "00" + str(lastfic) elif lastfic < 100: lastficstring = "0" + str(lastfic) else: lastficstring = str(lastfic) lastfile = "files.originalsmeta." + lastficstring lastread = import_module(lastfile) lastyear = (lastread.datewords[0])["date"].year if lastyear == firstyear: yearstring = str(firstyear) else: yearstring = str(firstyear) + "–" + str(lastyear) # write details element output = "build/byfandom/index.html" filewrite = open(output, "a") filewrite.write("