From 9ffedc1fc025554ce83db33a41b10c0ddc7b9476 Mon Sep 17 00:00:00 2001 From: CaliBrain Date: Fri, 29 Aug 2025 12:47:05 -0400 Subject: [PATCH] Several Bug fixes (#256) Emoji check fix Fix multi language books Fix DNS in Chromium Headless Fix DNS IPv6 address by un-abreviating them Fix typo in Quad9 DNS --- .vscode/launch.json | 3 ++- book_manager.py | 4 ++-- cloudflare_bypasser.py | 7 +++---- config.py | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0348984..339d2a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,7 +15,8 @@ "LOG_ROOT": "/tmp/cwa-book-downloader", "ENABLE_LOGGING": "true", "DOCKERMODE": "false", - "DEBUG": "true" + "DEBUG": "true", + "CUSTOM_DNS": "google", }, }, { diff --git a/book_manager.py b/book_manager.py index ea6baa3..95d9bfa 100644 --- a/book_manager.py +++ b/book_manager.py @@ -169,8 +169,8 @@ def _parse_book_info_page(soup: BeautifulSoup, book_id: str) -> BookInfo: data = soup.find_all("div", {"class": "main-inner"})[0].find_next("div") divs = list(data.children) - format = divs[13].text.split(" · ")[1].strip().lower() - size = divs[13].text.split(" · ")[2].strip().lower() + format = divs[13].text.split(" · ")[-6].strip().lower() + size = divs[13].text.split(" · ")[-5].strip().lower() every_url = soup.find_all("a") slow_urls_no_waitlist = set() diff --git a/cloudflare_bypasser.py b/cloudflare_bypasser.py index 47c5a83..0ddf460 100644 --- a/cloudflare_bypasser.py +++ b/cloudflare_bypasser.py @@ -72,7 +72,7 @@ def _is_bypassed(sb, escape_emojis : bool = True) -> bool: # Detect if there is an emoji in the page, any utf8 emoji, if so we are probably bypassed if escape_emojis: import emoji - emoji_list = emoji.emoji_list(text) + emoji_list = emoji.emoji_list(body) if len(emoji_list) >= 3: logger.debug(f"Detected emoji in page, we are probably bypassed len: {len(emoji_list)}") return True @@ -274,9 +274,8 @@ def _get_chromium_args(): except socket.gaierror: logger.warning(f"Could not resolve DoH hostname: {doh_hostname}") elif CUSTOM_DNS: - resolver_rules = [f"MAP * {dns_server}" for dns_server in CUSTOM_DNS] - if resolver_rules: - arguments.append(f'--host-resolver-rules={",".join(resolver_rules)}') + arguments.append(f'--dns-server="{",".join(CUSTOM_DNS)}"') + arguments.append(f'--disable-features=DnsOverHttps') except Exception as e: logger.error_trace(f"Error configuring DNS settings: {e}") return arguments diff --git a/config.py b/config.py index 8c33cce..e08b9ff 100644 --- a/config.py +++ b/config.py @@ -36,16 +36,16 @@ logger.info(f"CROSS_FILE_SYSTEM: {CROSS_FILE_SYSTEM}") _custom_dns = env._CUSTOM_DNS.lower().strip() _doh_server = "" if _custom_dns == "google": - CUSTOM_DNS = ["8.8.8.8", "8.8.4.4", "2001:4860:4860::8888", "2001:4860:4860::8844"] + CUSTOM_DNS = ["8.8.8.8", "8.8.4.4", "2001:4860:4860:0000:0000:0000:0000:8888", "2001:4860:4860:0000:0000:0000:0000:8844"] _doh_server = "https://dns.google/dns-query" elif _custom_dns == "quad9": - CUSTOM_DNS = ["9.9.9.9", "149.112.112.112", "2620:fe::fe", "26620:fe::9"] + CUSTOM_DNS = ["9.9.9.9", "149.112.112.112", "2620:00fe:0000:0000:0000:0000:0000:00fe", "2620:00fe:0000:0000:0000:0000:0000:0009"] _doh_server = "https://dns.quad9.net/dns-query" elif _custom_dns == "cloudflare": - CUSTOM_DNS = ["1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001"] + CUSTOM_DNS = ["1.1.1.1", "1.0.0.1", "2606:4700:4700:0000:0000:0000:0000:1111", "2606:4700:4700:0000:0000:0000:0000:1001"] _doh_server = "https://cloudflare-dns.com/dns-query" elif _custom_dns == "opendns": - CUSTOM_DNS = ["208.67.222.222", "208.67.220.220", "2620:119:35::35", "2620:119:53::53"] + CUSTOM_DNS = ["208.67.222.222", "208.67.220.220", "2620:0119:0035:0000:0000:0000:0000:0035", "2620:0119:0053:0000:0000:0000:0000:0053"] _doh_server = "https://doh.opendns.com/dns-query" else: _custom_dns_ip = _custom_dns.split(",")