From f17ed0569a1dea03b7607d8ce5409fc9bf8f77c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 9 Jul 2025 18:50:46 +0200 Subject: [PATCH] [common] raise ChallengeError for CF & DDG challenges (#1945) this sets bit 0x08 in the exit status bitmask --- gallery_dl/extractor/common.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index ae156f94..14d8a30a 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -155,17 +155,15 @@ class Extractor(): kwargs["verify"] = self._verify if "json" in kwargs: - json = kwargs["json"] - if json is not None: + if (json := kwargs["json"]) is not None: kwargs["data"] = util.json_dumps(json).encode() del kwargs["json"] - headers = kwargs.get("headers") - if headers: + if headers := kwargs.get("headers"): headers["Content-Type"] = "application/json" else: kwargs["headers"] = {"Content-Type": "application/json"} - response = None + response = challenge = None tries = 1 if self._interval: @@ -249,8 +247,12 @@ class Extractor(): self.log.warning(msg) return util.NullResponse(url, msg) - self.status |= exception.HttpError.code - raise exception.HttpError(msg, response) + if challenge is None: + exc = exception.HttpError(msg, response) + else: + exc = exception.ChallengeError(challenge, response) + self.status |= exc.code + raise exc def request_location(self, url, **kwargs): kwargs.setdefault("method", "HEAD")