Add files
This commit is contained in:
commit
6549deda7b
9 changed files with 1092 additions and 0 deletions
37
ao3scrape.py
Normal file
37
ao3scrape.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import AO3
|
||||
from os.path import exists
|
||||
|
||||
print("AO3 username:")
|
||||
theuser = input()
|
||||
print("Select output file format")
|
||||
print("azw3 [1], epub [2], html [3], mobi [4], pdf [5]")
|
||||
thetype = input()
|
||||
|
||||
if thetype == "1":
|
||||
ext = "azw3"
|
||||
filetype = "AZW3"
|
||||
elif thetype == "2":
|
||||
ext = "epub"
|
||||
filetype = "EPUB"
|
||||
elif thetype == "3":
|
||||
ext = "html"
|
||||
filetype = "HTML"
|
||||
elif thetype == "4":
|
||||
ext = "mobi"
|
||||
filetype = "MOBI"
|
||||
elif thetype == "5":
|
||||
ext = "pdf"
|
||||
filetype = "PDF"
|
||||
|
||||
user = AO3.User(theuser)
|
||||
|
||||
for work in user.get_works():
|
||||
if not exists(f"{work.title}-" + str(work.date_updated)[0:10] + "." + ext):
|
||||
work.reload()
|
||||
print("Downloading “" + (work.title) + "”")
|
||||
with open(f"{work.title}-" + str(work.date_updated)[0:10] + "." + ext, "wb") as file:
|
||||
file.write(work.download(filetype))
|
||||
else:
|
||||
print("“" + (work.title) + "” is already downloaded, skipping")
|
||||
|
||||
print("Done.")
|
Loading…
Add table
Add a link
Reference in a new issue