diff --git a/src/api/src/main.py b/src/api/src/main.py index 93eae99..854676a 100644 --- a/src/api/src/main.py +++ b/src/api/src/main.py @@ -161,6 +161,13 @@ async def handle_download( else: cookies = None + if format == DownloadFormat.pdf and not PDFS_ENABLED: + logger.error("PDF Downloads not enabled.") + return HTMLResponse( + status_code=403, + content='PDF Downloads have been disabled by the server administrator. Support is available on the Discord', + ) + match mode: case DownloadMode.story: story_id = download_id @@ -195,12 +202,6 @@ async def handle_download( book = EPUBGenerator(metadata, part_trees, cover_data, images) media_type = "application/epub+zip" case DownloadFormat.pdf: - if not PDFS_ENABLED: - logger.error("PDF Downloads not enabled.") - return HTMLResponse( - status_code=403, - content='PDF Downloads have been disabled by the server administrator. Support is available on the Discord', - ) author_image = await fetch_image( metadata["user"]["avatar"].replace("-256-", "-512-") )