Skip to content

Commit

Permalink
Add CloudFlare detection for failed image fetches
Browse files Browse the repository at this point in the history
  • Loading branch information
mizaki committed May 28, 2024
1 parent dbec6ed commit bc31d8f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gcd_talker/gcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bc31d8f

Please sign in to comment.