Sort fics properly

This commit is contained in:
trémeur 2023-11-20 21:26:41 +00:00
parent d1003797f2
commit 663cac35b9
5 changed files with 59 additions and 12 deletions

View file

@ -90,26 +90,27 @@ def charlist(local=False):
except:
revealed = True
if revealed == True:
ficdict = {"thefic":ficcount,"thedate":(fileread.datewords[-1])["date"]}
if searchfandom in fileread.fandom:
# append to lists
try:
if character in fileread.charpov:
povcount.append(ficcount)
povcount.append(ficdict)
except:
pass
try:
if character in fileread.charmain:
maincount.append(ficcount)
maincount.append(ficdict)
except:
pass
try:
if character in fileread.charsecondary:
secondarycount.append(ficcount)
secondarycount.append(ficdict)
except:
pass
try:
if character in fileread.charmention:
mentioncount.append(ficcount)
mentioncount.append(ficdict)
except:
pass
# write details element
@ -132,25 +133,41 @@ def charlist(local=False):
filewrite = open(output, "a")
filewrite.write("<h1>POV character</h1>\n")
filewrite.close()
povcount = sorted(povcount,key=lambda d: d["thedate"],reverse=True)
newpov = []
for fic in povcount:
newpov.append(fic["thefic"])
for fic in newpov:
makeheader.ficgen(fic,False,output,local)
if len(maincount) > 0:
filewrite = open(output, "a")
filewrite.write("<h1>Main character</h1>\n")
filewrite.close()
maincount = sorted(maincount,key=lambda d: d["thedate"],reverse=True)
newmain = []
for fic in maincount:
newmain.append(fic["thefic"])
for fic in newmain:
makeheader.ficgen(fic,False,output,local)
if len(secondarycount) > 0:
filewrite = open(output, "a")
filewrite.write("<h1>Secondary character</h1>\n")
filewrite.close()
secondarycount = sorted(secondarycount,key=lambda d: d["thedate"],reverse=True)
newsecondary = []
for fic in secondarycount:
newsecondary.append(fic["thefic"])
for fic in newsecondary:
makeheader.ficgen(fic,False,output,local)
if len(mentioncount) > 0:
filewrite = open(output, "a")
filewrite.write("<h1>Mentioned</h1>\n")
filewrite.close()
mentioncount = sorted(mentioncount,key=lambda d: d["thedate"],reverse=True)
newmention = []
for fic in mentioncount:
newmention.append(fic["thefic"])
for fic in newmention:
makeheader.ficgen(fic,False,output,local)
filewrite = open(output, "a")
filewrite.write("</details>\n")