From bc31d8f3f3bee9aa0e65de6b4711841cac0aded5 Mon Sep 17 00:00:00 2001 From: Mizaki Date: Tue, 28 May 2024 01:25:22 +0100 Subject: [PATCH] Add CloudFlare detection for failed image fetches --- gcd_talker/gcd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gcd_talker/gcd.py b/gcd_talker/gcd.py index 0559e8d..17d0620 100644 --- a/gcd_talker/gcd.py +++ b/gcd_talker/gcd.py @@ -23,7 +23,7 @@ import pathlib import re import sqlite3 -from typing import Any, Callable +from typing import Any, Callable, TypedDict from urllib.parse import urljoin import requests @@ -37,7 +37,6 @@ from comictalker.comiccacher import Series as CCSeries from comictalker.comictalker import ComicTalker, TalkerDataError, TalkerNetworkError from pyrate_limiter import Limiter, RequestRate -from typing_extensions import TypedDict from urllib3.exceptions import LocationParseError from urllib3.util import parse_url @@ -590,8 +589,11 @@ def _find_issue_images(self, issue_id: int) -> tuple[str, list[str]]: else: variants.append(src) else: - # TODO check for cloudflare activation and log - logger.debug(f"No image found for ID: {issue_id}") + cf_challenge = covers_page.findAll(id="challenge-error-title") + if cf_challenge: + logger.info(f"CloudFlare active, cannot access image for ID: {issue_id}") + else: + logger.info(f"No image found for ID: {issue_id}") return cover, variants