Update download handling and URL selection logic (#203)

Changed intermediate download file naming in backend.py to use
.crdownload extension. Refactored URL selection logic in book_manager.py
to adjust order and inclusion based on Cloudflare bypass and donator
key. Added extra Chromium arguments in cloudflare_bypasser.py to ignore
certificate and SSL errors for improved bypass reliability.
This commit is contained in:
CaliBrain
2025-07-14 16:05:09 -04:00
committed by GitHub
parent 8c8cf4a4af
commit e1d94f9cb5
3 changed files with 12 additions and 7 deletions
+1 -2
View File
@@ -136,8 +136,7 @@ def _download_book(book_id: str) -> Optional[str]:
if CUSTOM_SCRIPT:
logger.info(f"Running custom script: {CUSTOM_SCRIPT}")
subprocess.run([CUSTOM_SCRIPT, book_path])
intermediate_path = INGEST_DIR / book_id # Without extension
intermediate_path = INGEST_DIR / f"{book_id}.crdownload"
final_path = INGEST_DIR / book_name
if os.path.exists(book_path):
+4 -5
View File
@@ -219,9 +219,7 @@ def _parse_book_info_page(soup: BeautifulSoup, book_id: str) -> BookInfo:
pass
if USE_CF_BYPASS:
urls = (
list(slow_urls_no_waitlist)
+ list(external_urls_libgen)
urls = (list(external_urls_libgen)
+ list(slow_urls_with_waitlist)
+ list(external_urls_z_lib)
)
@@ -229,10 +227,11 @@ def _parse_book_info_page(soup: BeautifulSoup, book_id: str) -> BookInfo:
urls = (
list(external_urls_libgen)
+ list(external_urls_z_lib)
+ list(slow_urls_no_waitlist)
+ list(slow_urls_with_waitlist)
)
if AA_DONATOR_KEY != "":
urls = list(slow_urls_no_waitlist) + urls
for i in range(len(urls)):
urls[i] = downloader.get_absolute_url(AA_BASE_URL, urls[i])
+7
View File
@@ -110,6 +110,13 @@ def _bypass(sb, max_retries: int = MAX_RETRY) -> None:
def _get_chromium_args():
arguments = [
# Ignore certificate and SSL errors (similar to curl's --insecure)
"--ignore-certificate-errors",
"--ignore-ssl-errors",
"--allow-running-insecure-content",
"--disable-web-security",
"--ignore-certificate-errors-spki-list",
"--ignore-certificate-errors-skip-list"
]
# Conditionally add verbose logging arguments