From ec80f0458631d7fa1c0055115650313e53f29236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Wed, 22 Mar 2023 15:32:01 +0000 Subject: [PATCH] Add (dodgy) boolean for title inclusion in fic headers --- fic-header.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fic-header.py b/fic-header.py index 7e32874..49dc6e5 100644 --- a/fic-header.py +++ b/fic-header.py @@ -11,12 +11,14 @@ data = { if os.path.exists("ficheader.html"): os.remove("ficheader.html") -thefile = open("ficheader.html", "a") +thefile = open("ficheader.html", "a") with requests.Session() as s: response = s.post(login_url , data) - print("Work ID: ") + print("Work ID:") id = input() + print("Use title? (y/n)") + thetitle = input() url = "https://archiveofourown.org/works/" + str(id) ficpage = s.get(url) ficsoup = BeautifulSoup(ficpage.content, "html.parser") @@ -138,7 +140,10 @@ with requests.Session() as s: mastersoup = BeautifulSoup(masterlist.content, "html.parser") ficno = int(mastersoup.find("span", class_="ficno").text.strip()) + 1 thefile.write("
\n") - thefile.write("

" + str(ficno) + " " + title + "

\n") + if thetitle == "y": + thefile.write("

" + str(ficno) + " " + title + "

\n") + else: + thefile.write("

" + str(ficno) + "

\n") thefile.write("