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

@ -78,13 +78,14 @@ def shiplist(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 fileread.ship[0] == ship:
maincount.append(ficcount)
maincount.append(ficdict)
elif ship in fileread.ship:
secondarycount.append(ficcount)
secondarycount.append(ficdict)
except:
pass
# write details element
@ -103,13 +104,21 @@ def shiplist(local=False):
filewrite = open(output, "a")
filewrite.write("<h1>Main ship</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 ship</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)
filewrite = open(output, "a")
filewrite.write("</details>\n")