Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CloudFlare detection for failed image fetches #17

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading