[zerochan] improve redirect handling, add 'redirects' option (#5891)

This commit is contained in:
Mike Fährmann
2024-08-10 11:32:30 +02:00
parent 6e7da6310c
commit 87a14a50e7
2 changed files with 16 additions and 2 deletions

View File

@@ -198,11 +198,15 @@ class ZerochanTagExtractor(ZerochanExtractor):
while True:
response = self.request(url, params=params, allow_redirects=False)
if response.status_code >= 300:
url = text.urljoin(self.root, response.headers["location"])
response = self.request(url, params=params)
data = response.json()
self.log.warning("HTTP redirect to %s", url)
if self.config("redirects"):
continue
raise exception.StopExtraction()
data = response.json()
try:
posts = data["items"]
except Exception: