1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[pixiv] make '_request_ajax()' non-fatal

This commit is contained in:
Mike Fährmann 2024-10-11 07:55:02 +02:00
parent bc954eb7e4
commit 1f5f04e673
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -79,7 +79,8 @@ class PixivExtractor(Extractor):
if self.sanity_workaround and not work.get("caption") and \
not work.get("_mypixiv"):
body = self._request_ajax("/illust/" + str(work["id"]))
work["caption"] = text.unescape(body["illustComment"])
if body:
work["caption"] = text.unescape(body["illustComment"])
if transform_tags:
transform_tags(work)
@ -177,8 +178,10 @@ class PixivExtractor(Extractor):
def _request_ajax(self, endpoint):
url = "{}/ajax{}".format(self.root, endpoint)
data = self.request(url, headers=self.headers_web).json()
return data["body"]
try:
return self.request(url, headers=self.headers_web).json()["body"]
except Exception:
return None
def _extract_ajax(self, work, body):
url = self._extract_ajax_url(body)