Improve functions for showing genre on stats page + RSS
This commit is contained in:
parent
84161b7612
commit
1957f92f2c
3 changed files with 80 additions and 23 deletions
27
feed.py
27
feed.py
|
@ -5,7 +5,7 @@ from importlib import import_module
|
||||||
Code to generate RSS feed
|
Code to generate RSS feed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def feedgen():
|
def feedgen(local=False):
|
||||||
# delete existing file
|
# delete existing file
|
||||||
if os.path.exists("build/feed.xml"):
|
if os.path.exists("build/feed.xml"):
|
||||||
os.remove("build/feed.xml")
|
os.remove("build/feed.xml")
|
||||||
|
@ -103,7 +103,14 @@ def feedgen():
|
||||||
therating = "X"
|
therating = "X"
|
||||||
filewrite.write(", rated " + therating)
|
filewrite.write(", rated " + therating)
|
||||||
if len(origread.genre) > 1:
|
if len(origread.genre) > 1:
|
||||||
filewrite.write(", " + origread.genre[1])
|
genred = False
|
||||||
|
for thegenre in origread.genre:
|
||||||
|
if genred == False:
|
||||||
|
if thegenre == "gen" or thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash" or thegenre == "het" or thegenre == "pre-het" or thegenre == "femslash" or thegenre == "poly" or thegenre == "masturbation":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
filewrite.write(", " + thegenre)
|
||||||
|
genred = True
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
filewrite.write(thefile.fandomtext)
|
filewrite.write(thefile.fandomtext)
|
||||||
|
@ -130,11 +137,23 @@ def feedgen():
|
||||||
therating = "X"
|
therating = "X"
|
||||||
filewrite.write(", rated " + therating)
|
filewrite.write(", rated " + therating)
|
||||||
if len(thefile.genre) > 1:
|
if len(thefile.genre) > 1:
|
||||||
filewrite.write(", " + thefile.genre[1])
|
genred = False
|
||||||
|
for thegenre in thefile.genre:
|
||||||
|
if genred == False:
|
||||||
|
if thegenre == "gen" or thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash" or thegenre == "het" or thegenre == "pre-het" or thegenre == "femslash" or thegenre == "poly" or thegenre == "masturbation":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
filewrite.write(", " + thegenre)
|
||||||
|
genred = True
|
||||||
filewrite.write("</title>\n<pubDate>")
|
filewrite.write("</title>\n<pubDate>")
|
||||||
futuredate = date + datetime.timedelta(days=2)
|
futuredate = date + datetime.timedelta(days=2)
|
||||||
filewrite.write(futuredate.strftime("%a, %-d %b %Y"))
|
filewrite.write(futuredate.strftime("%a, %-d %b %Y"))
|
||||||
filewrite.write(" 00:00:00 UT</pubDate>\n<link>https://tre.praze.net/fic/masterlist#fic" + ficcountstring + "</link>\n<guid isPermaLink=\"false\">praze-fic-" + ficcountstring)
|
filewrite.write(" 00:00:00 UT</pubDate>\n<link>")
|
||||||
|
if local:
|
||||||
|
filewrite.write("/home/mdd/Documents/drive/proj/fic-archive/build/masterlist")
|
||||||
|
else:
|
||||||
|
filewrite.write("https://tre.praze.net/fic/masterlist")
|
||||||
|
filewrite.write("#fic" + ficcountstring + "</link>\n<guid isPermaLink=\"false\">praze-fic-" + ficcountstring)
|
||||||
datecount = 0
|
datecount = 0
|
||||||
dateindex = 0
|
dateindex = 0
|
||||||
for instalment in thefile.datewords:
|
for instalment in thefile.datewords:
|
||||||
|
|
|
@ -19,8 +19,8 @@ except:
|
||||||
local = False
|
local = False
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
feed.feedgen()
|
|
||||||
if local == True:
|
if local == True:
|
||||||
|
feed.feedgen(True)
|
||||||
masterlist.listgen(True)
|
masterlist.listgen(True)
|
||||||
commentpage.allcomments(True)
|
commentpage.allcomments(True)
|
||||||
commentpage.commentindex(True)
|
commentpage.commentindex(True)
|
||||||
|
@ -31,6 +31,7 @@ if __name__ == "__main__":
|
||||||
verifygen.verifygen(True)
|
verifygen.verifygen(True)
|
||||||
statsgen.yeargen(True)
|
statsgen.yeargen(True)
|
||||||
else:
|
else:
|
||||||
|
feed.feedgen()
|
||||||
masterlist.listgen()
|
masterlist.listgen()
|
||||||
commentpage.allcomments()
|
commentpage.allcomments()
|
||||||
commentpage.commentindex()
|
commentpage.commentindex()
|
||||||
|
|
73
statsgen.py
73
statsgen.py
|
@ -34,11 +34,15 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
|
||||||
fandom = "/".join(origfile.fandom)
|
fandom = "/".join(origfile.fandom)
|
||||||
except:
|
except:
|
||||||
fandom = "/".join(fileread.fandom)
|
fandom = "/".join(fileread.fandom)
|
||||||
|
thechars = ""
|
||||||
try:
|
try:
|
||||||
if "OW" not in origfile.fandom:
|
if "OW" not in origfile.fandom:
|
||||||
try:
|
if "gen" not in origfile.genre:
|
||||||
thechars = origfile.ship[0]
|
try:
|
||||||
except:
|
thechars = origfile.ship[0]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
chars = []
|
chars = []
|
||||||
try:
|
try:
|
||||||
chars.extend(origfile.charpov)
|
chars.extend(origfile.charpov)
|
||||||
|
@ -56,9 +60,12 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
|
||||||
thechars = ""
|
thechars = ""
|
||||||
except:
|
except:
|
||||||
if "OW" not in fileread.fandom:
|
if "OW" not in fileread.fandom:
|
||||||
try:
|
if "gen" not in fileread.genre:
|
||||||
thechars = fileread.ship[0]
|
try:
|
||||||
except:
|
thechars = fileread.ship[0]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
chars = []
|
chars = []
|
||||||
try:
|
try:
|
||||||
chars.extend(fileread.charpov)
|
chars.extend(fileread.charpov)
|
||||||
|
@ -74,6 +81,8 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
|
||||||
thechars = ""
|
thechars = ""
|
||||||
else:
|
else:
|
||||||
thechars = ""
|
thechars = ""
|
||||||
|
if thechars == "":
|
||||||
|
thechars = "no characters specified"
|
||||||
if fileread.language == "fr":
|
if fileread.language == "fr":
|
||||||
language = "French"
|
language = "French"
|
||||||
else:
|
else:
|
||||||
|
@ -82,10 +91,35 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
|
||||||
rating = origfile.rating
|
rating = origfile.rating
|
||||||
except:
|
except:
|
||||||
rating = fileread.rating
|
rating = fileread.rating
|
||||||
|
genre = []
|
||||||
try:
|
try:
|
||||||
genre = origfile.genre[0]
|
for thegenre in origfile.genre:
|
||||||
|
if thegenre == "gen":
|
||||||
|
genre.append(thegenre)
|
||||||
|
elif thegenre == "het" or thegenre == "pre-het":
|
||||||
|
genre.append("het")
|
||||||
|
elif thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash":
|
||||||
|
genre.append("slash")
|
||||||
|
elif thegenre == "femslash":
|
||||||
|
genre.append("femslash")
|
||||||
|
elif thegenre == "poly":
|
||||||
|
genre.append("multi")
|
||||||
|
elif thegenre == "masturbation":
|
||||||
|
genre.append("other")
|
||||||
except:
|
except:
|
||||||
genre = fileread.genre[0]
|
for thegenre in fileread.genre:
|
||||||
|
if thegenre == "gen":
|
||||||
|
genre.append(thegenre)
|
||||||
|
elif thegenre == "het" or thegenre == "pre-het":
|
||||||
|
genre.append("het")
|
||||||
|
elif thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash":
|
||||||
|
genre.append("slash")
|
||||||
|
elif thegenre == "femslash":
|
||||||
|
genre.append("femslash")
|
||||||
|
elif thegenre == "poly":
|
||||||
|
genre.append("multi")
|
||||||
|
elif thegenre == "masturbation":
|
||||||
|
genre.append("other")
|
||||||
try:
|
try:
|
||||||
if origfile.warnings:
|
if origfile.warnings:
|
||||||
warnings = "?!"
|
warnings = "?!"
|
||||||
|
@ -130,16 +164,19 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
|
||||||
ficstring += " <span style=\"background-color:#eb7d10;color:white; font-family:serif\"> M </span>"
|
ficstring += " <span style=\"background-color:#eb7d10;color:white; font-family:serif\"> M </span>"
|
||||||
elif rating == "e":
|
elif rating == "e":
|
||||||
ficstring += " <span style=\"background-color:#9c0000;color:white; font-family:serif\"> E </span>"
|
ficstring += " <span style=\"background-color:#9c0000;color:white; font-family:serif\"> E </span>"
|
||||||
if genre == "gen":
|
for thegenre in genre:
|
||||||
ficstring += " <span style=\"background-color:#8ab60b;color:white; font-family:serif\"> ☉ </span>"
|
if thegenre == "gen":
|
||||||
elif genre == "slash" or genre == "pre-slash" or genre == "poly slash":
|
ficstring += " <span style=\"background-color:#8ab60b;color:white; font-family:serif\"> ☉ </span>"
|
||||||
ficstring += " <span style=\"background-color:#1256b6;color:white; font-family:serif\"> ♂ </span>"
|
elif thegenre == "slash":
|
||||||
elif genre == "het" or genre == "pre-het":
|
ficstring += " <span style=\"background-color:#1256b6;color:white; font-family:serif\"> ♂ </span>"
|
||||||
ficstring += " <span style=\"background-color:#670840;color:white; font-family:serif\"> ⚤ </span>"
|
elif thegenre == "het":
|
||||||
elif genre == "femslash":
|
ficstring += " <span style=\"background-color:#670840;color:white; font-family:serif\"> ⚤ </span>"
|
||||||
ficstring += " <span style=\"background-color:#d50636;color:white; font-family:serif\"> ♀ </span>"
|
elif thegenre == "femslash":
|
||||||
elif genre == "poly":
|
ficstring += " <span style=\"background-color:#d50636;color:white; font-family:serif\"> ♀ </span>"
|
||||||
ficstring += " <span><span style=\"background:linear-gradient(0deg, rgba(160,0,24,1) 0%, rgba(160,0,24,1) 49%, rgba(171,203,0,1) 50%, rgba(171,203,0,1) 100%);\"> </span><span style=\"background: linear-gradient(0deg, rgba(0,51,148,1) 0%, rgba(0,51,148,1) 49%, rgba(129,0,108,1) 50%, rgba(129,0,108,1) 100%);\"> </span></span>"
|
elif thegenre == "poly":
|
||||||
|
ficstring += " <span><span style=\"background:linear-gradient(0deg, rgba(160,0,24,1) 0%, rgba(160,0,24,1) 49%, rgba(171,203,0,1) 50%, rgba(171,203,0,1) 100%);\"> </span><span style=\"background: linear-gradient(0deg, rgba(0,51,148,1) 0%, rgba(0,51,148,1) 49%, rgba(129,0,108,1) 50%, rgba(129,0,108,1) 100%);\"> </span></span>"
|
||||||
|
elif thegenre == "other":
|
||||||
|
ficstring += " <span style=\"background-color:black;color:white; font-family:serif\"> ☿ </span>"
|
||||||
if warnings:
|
if warnings:
|
||||||
ficstring += " <span style=\"background-color:#eb7d10;color:white; font-family:serif\"> !<small>?</small> </span>"
|
ficstring += " <span style=\"background-color:#eb7d10;color:white; font-family:serif\"> !<small>?</small> </span>"
|
||||||
ficstring += " <code>" + str(words) + "</code>"
|
ficstring += " <code>" + str(words) + "</code>"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue