[pixiv] fix artworks downloads when using expired cookies (#7987)

This commit is contained in:
Mike Fährmann
2025-08-07 18:55:52 +02:00
parent ba174b1a06
commit f2a58118eb
2 changed files with 10 additions and 4 deletions

View File

@@ -446,16 +446,14 @@ class PixivArtworksExtractor(PixivExtractor):
if self.sanity_workaround: if self.sanity_workaround:
body = self._request_ajax( body = self._request_ajax(
f"/user/{self.user_id}/profile/all") f"/user/{self.user_id}/profile/all")
if not body:
return ()
try: try:
ajax_ids = list(map(int, body["illusts"])) ajax_ids = list(map(int, body["illusts"]))
ajax_ids.extend(map(int, body["manga"])) ajax_ids.extend(map(int, body["manga"]))
ajax_ids.sort() ajax_ids.sort()
except Exception as exc: except Exception as exc:
self.log.debug("", exc_info=exc)
self.log.warning("u%s: Failed to collect artwork IDs " self.log.warning("u%s: Failed to collect artwork IDs "
"using AJAX API (%s: %s)", "using AJAX API", self.user_id)
self.user_id, exc.__class__.__name__, exc)
else: else:
works = self._extend_sanity(works, ajax_ids) works = self._extend_sanity(works, ajax_ids)

View File

@@ -102,6 +102,14 @@ __tests__ = (
}, },
}, },
{
"#url" : "https://www.pixiv.net/en/users/173530/artworks",
"#comment" : "Invalid PHPSESSID cookie",
"#class" : pixiv.PixivArtworksExtractor,
"#options" : {"cookies": {"PHPSESSID": "12345_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}},
"#sha1_url": "852c31ad83b6840bacbce824d85f2a997889efb7",
},
{ {
"#url" : "https://www.pixiv.net/en/users/173530/artworks/%E6%89%8B%E3%81%B6%E3%82%8D", "#url" : "https://www.pixiv.net/en/users/173530/artworks/%E6%89%8B%E3%81%B6%E3%82%8D",
"#comment" : "illusts with specific tag", "#comment" : "illusts with specific tag",