Start redesign

This commit is contained in:
mez 2025-07-12 19:22:32 +01:00
parent 958da8737b
commit 8b66e17c20
3 changed files with 982 additions and 1 deletions

1
.gitignore vendored
View file

@ -18,3 +18,4 @@ build/secret/*.png
build/emacs.jpg
files/
build/stats/*/index.html
index.html

557
archivesearch.py Normal file
View file

@ -0,0 +1,557 @@
import datetime, os, re
from importlib import import_module
starttime = datetime.datetime(1998,1,1)
endtime = datetime.datetime.today().date()
choosetime = input("Select a date range? [y/N]\n")
if choosetime == "y":
choosestart = input("Select a start date? [Y/n]\n")
if choosestart != "n":
starttimestring = input("Input start date (YYYYMMDD):\n")
starttime = datetime.datetime.strptime(starttimestring, "%Y%m%d")
chooseend = input("Select an end date? [Y/n]\n")
if chooseend != "n":
endtimestring = input("Input end date (YYYYMMDD):\n")
endtime = datetime.datetime.strptime(endtimestring, "%Y%m%d")
while endtime < starttime:
print("End date is before start date")
choosestart = input("Select a new start date? [Y/n]\n")
if choosestart != "n":
starttimestring = input("Input start date (YYYYMMDD):\n")
starttime = datetime.datetime.strptime(starttimestring, "%Y%m%d")
endtimestring = input("Input end date (YYYYMMDD):\n")
endtime = datetime.datetime.strptime(endtimestring, "%Y%m%d")
if starttime == datetime.datetime(1998,1,1):
if endtime == datetime.datetime.today().date():
print("Date range selected: all time")
else:
print("Date range selected: start to " + endtime.strftime("%Y-%m-%d"))
elif endtime == datetime.datetime.today().date():
print("Date range selected: " + starttime.strftime("%Y-%m-%d") + " to now")
else:
print("Date range selected: " + starttime.strftime("%Y-%m-%d") + " to " + endtime.strftime("%Y-%m-%d"))
if endtime == datetime.datetime.today().date():
endtime = datetime.datetime.today()
minwords = 0
maxwords = 500000
choosewords = input("Select a word count range? [y/N]\n")
if choosewords == "y":
chooseminwords = input("Select a minimum word count? [Y/n]\n")
if chooseminwords != "n":
minwords = int(input("Input minimum word count:\n"))
choosemaxwords = input("Select a maximum word count? [Y/n]\n")
if choosemaxwords != "n":
maxwords = int(input("Input maximum word count:\n"))
while maxwords < minwords:
print("Minimum word count exceeds maximum word count")
chooseminwords = input("Select a new minimum word count? [Y/n]\n")
if chooseminwords != "n":
minwords = int(input("Input minimum word count:\n"))
maxwords = int(input("Input maximum word count:\n"))
if minwords == 0:
if maxwords == 500000:
print("Word count range selected: all")
else:
print("Word count range selected: up to " + str(maxwords))
elif maxwords == 500000:
print("Word count range selected: at least " + str(minwords))
else:
print("Word count range selected: " + str(minwords) + " to " + str(maxwords))
chooselang = input("Choose languages: English only [e], French only [f], or all [any key]\n")
ficlist = []
ficcount = 500
while ficcount > 0:
fileread = ""
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)
elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"):
ficfile = "files.translationsmeta." + ficcountstring
fileread = import_module(ficfile)
if fileread:
if (fileread.datewords[0])["date"] >= starttime:
if (fileread.datewords[-1])["date"] <= endtime:
sumwords = 0
for instalment in fileread.datewords:
sumwords = sumwords + instalment["words"]
if minwords <= sumwords <= maxwords:
if chooselang == "e":
if fileread.language == "en":
ficlist.append(ficcount)
elif chooselang == "f":
if fileread.language == "fr":
ficlist.append(ficcount)
else:
ficlist.append(ficcount)
fandomslist = []
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
try:
fandomslist.extend(fileread.fandom)
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
fandomslist.extend(origread.fandom)
except:
pass
fandomlist = []
for fandom in fandomslist:
if fandom not in fandomlist:
fandomlist.append(fandom)
fandomlist.sort()
fandomnumbers = []
for fandom in fandomlist:
thenumber = 0
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
try:
if fandom in fileread.fandom:
thenumber += 1
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
if fandom in origread.fandom:
thenumber += 1
except:
pass
fandomnumbers.append({"fandom":fandom,"number":thenumber,"filtercheck":False})
fandomnumbers = sorted(fandomnumbers, key=lambda d: d["number"],reverse=True)
print("Fandoms:")
for fandom in fandomnumbers:
if fandom["number"] > 1:
print(fandom["fandom"] + ": " + str(fandom["number"]) + " fics")
else:
print(fandom["fandom"] + ": " + str(fandom["number"]) + " fic")
fandomfilter = input("Filter by fandom? [y/N]\n")
if fandomfilter == "y":
filteredfandoms = []
fandommin = 0
fandommax = 500
choosemin = input("Choose only fandoms over a certain number of fics? [y/N]\n")
if choosemin == "y":
minstring = input("Minimum number of fics:\n")
fandommin = int(minstring)
choosemax = input("Choose only fandoms under a certain number of fics? [y/N]\n")
if choosemax == "y":
maxstring = input("Maximum number of fics:\n")
fandommax = int(maxstring)
refinefandoms = "y"
if choosemin == "y" or choosemax == "y":
refinefandoms = input("Refine fandoms further? [y/N]\n")
for fandom in fandomnumbers:
if fandommin <= fandom["number"] <= fandommax:
if refinefandoms == "y":
while fandom["filtercheck"] == False:
thefilter = input("Include " + fandom["fandom"] + " (" + str(fandom["number"]) + ")? [y/n]\n")
if thefilter == "y":
filteredfandoms.append(fandom)
fandom["filtercheck"] = True
elif thefilter == "n":
fandom["filtercheck"] = True
else:
print("Choose y or n")
continue
else:
filteredfandoms.append(fandom)
newficlist = []
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
for fandom in filteredfandoms:
try:
if fandom["fandom"] in fileread.fandom:
newficlist.append(fic)
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
if fandom["fandom"] in origread.fandom:
newficlist.append(fic)
except:
pass
ficlist = list(dict.fromkeys(newficlist))
shipslist = []
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
try:
for ship in fileread.ship:
if ship != None:
shipslist.append(ship)
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
try:
for ship in origread.ship:
if ship != None:
shipslist.append(ship)
except:
shipslist.append("Gen")
except:
shipslist.append("Gen")
shiplist = []
for ship in shipslist:
if ship not in shiplist:
shiplist.append(ship)
shiplist.sort()
genlist = {}
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
try:
if ship in fileread.ship:
pass
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
try:
if ship in origread.ship:
pass
except:
genlist[fic] = True
except:
genlist[fic] = True
shipnumbers = []
for ship in shiplist:
if ship != "Gen":
thenumber = 0
for fic in ficlist:
if fic not in genlist.keys():
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
try:
if ship in fileread.ship:
thenumber += 1
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
try:
if ship in origread.ship:
thenumber += 1
except:
pass
except:
pass
if thenumber > 0:
shipnumbers.append({"ship":ship,"number":thenumber,"filtercheck":False})
shipnumbers.append({"ship":"Gen","number":len(genlist),"filtercheck":False})
shipnumbers = sorted(shipnumbers, key=lambda d: d["number"],reverse=True)
# print(shipnumbers)
print("Ships:")
for ship in shipnumbers:
if ship["number"] > 1:
print(ship["ship"] + ": " + str(ship["number"]) + " fics")
else:
print(ship["ship"] + ": " + str(ship["number"]) + " fic")
shipfilter = input("Filter by ship? [y/N]\n")
if shipfilter == "y":
filteredships = []
shipmin = 0
shipmax = 500
choosemin = input("Choose only ships over a certain number of fics? [y/N]\n")
if choosemin == "y":
minstring = input("Minimum number of fics:\n")
shipmin = int(minstring)
choosemax = input("Choose only ships under a certain number of fics? [y/N]\n")
if choosemax == "y":
maxstring = input("Maximum number of fics:\n")
shipmax = int(maxstring)
refineships = "y"
if choosemin == "y" or choosemax == "y":
refineships = input("Refine ships further? [y/N]\n")
for ship in shipnumbers:
if shipmin <= ship["number"] <= shipmax:
if refineships == "y":
while ship["filtercheck"] == False:
thefilter = input("Include " + ship["ship"] + " (" + str(ship["number"]) + ")? [y/n]\n")
if thefilter == "y":
filteredships.append(ship)
ship["filtercheck"] = True
elif thefilter == "n":
ship["filtercheck"] = True
else:
print("Choose y or n")
continue
else:
filteredships.append(ship)
newficlist = []
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
for ship in filteredships:
if ship["ship"] != "Gen":
try:
if ship["ship"] in fileread.ship:
newficlist.append(fic)
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
if ship["ship"] in origread.ship:
newficlist.append(fic)
except:
pass
else:
try:
if fileread.ship:
pass
except:
try:
origno = fileread.original
if origno < 10:
orignostring = "00" + str(origno)
elif origno < 100:
orignostring = "0" + str(origno)
else:
orignostring = str(origno)
if os.path.exists("files/originalsmeta/" + orignostring + ".py"):
orignofile = "files.originalsmeta." + orignostring
origread = import_module(orignofile)
try:
if fileread.ship:
pass
except:
newficlist.append(fic)
except:
newficlist.append(fic)
ficlist = list(dict.fromkeys(newficlist))
totalwords = 0
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
for instalment in fileread.datewords:
totalwords = totalwords + instalment["words"]
print("Total word count: " + str(totalwords) + "\n")
print("Summaries of selected fics:\n")
for fic in ficlist:
fileread = ""
if fic < 10:
ficstring = "00" + str(fic)
elif fic < 100:
ficstring = "0" + str(fic)
else:
ficstring = str(fic)
if os.path.exists("files/originalsmeta/" + ficstring + ".py"):
ficfile = "files.originalsmeta." + ficstring
fileread = import_module(ficfile)
elif os.path.exists("files/translationsmeta/" + ficstring + ".py"):
ficfile = "files.translationsmeta." + ficstring
fileread = import_module(ficfile)
if fileread:
print("Fic " + str(fic) + ", " + (fileread.datewords[-1])["date"].strftime("%-d %B %Y") + " • https://tre.praze.net/fic/single/" + ficstring)
try:
if fileread.showtitle:
print("\033[1m" + fileread.title + "\033[0m")
except:
pass
try:
print(re.sub("<[^<]+?>","",(re.sub("&nbsp;"," ",fileread.summary))))
except:
pass
print("\n")

423
new.py Normal file

File diff suppressed because one or more lines are too long