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.")