From 33161da1210ac885177aa6b04f29a53127001f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 22 Oct 2024 16:31:37 +0200 Subject: [PATCH] [pixiv] add 'captions' option (#4327) make extra requests for empty captions independent of 'sanity' --- docs/configuration.rst | 11 +++++++++++ gallery_dl/extractor/pixiv.py | 6 ++---- test/results/pixiv.py | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 51bdd4f059..ca6d6485bb 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3520,6 +3520,17 @@ Description Note: This requires 1 additional API request per bookmarked post. +extractor.pixiv.captions +------------------------ +Type + ``bool`` +Default + ``false`` +Description + For works with seemingly empty ``caption`` metadata, + try to grab the actual ``caption`` value using the AJAX API. + + extractor.pixiv.comments ------------------------ Type diff --git a/gallery_dl/extractor/pixiv.py b/gallery_dl/extractor/pixiv.py index 49fbeee21b..ab8c59794f 100644 --- a/gallery_dl/extractor/pixiv.py +++ b/gallery_dl/extractor/pixiv.py @@ -38,6 +38,7 @@ def _init(self): self.meta_user = self.config("metadata") self.meta_bookmark = self.config("metadata-bookmark") self.meta_comments = self.config("comments") + self.meta_captions = self.config("captions") def items(self): tags = self.config("tags", "japanese") @@ -76,7 +77,7 @@ def transform_tags(work): detail = self.api.illust_bookmark_detail(work["id"]) work["tags_bookmark"] = [tag["name"] for tag in detail["tags"] if tag["is_registered"]] - if self.sanity_workaround and not work.get("caption") and \ + if self.meta_captions and not work.get("caption") and \ not work.get("_mypixiv") and not work.get("_ajax"): body = self._request_ajax("/illust/" + str(work["id"])) if body: @@ -294,9 +295,6 @@ def _make_work(kind, url, user): "x_restrict" : 0, } - def _web_to_mobile(self, work): - return work - def works(self): """Return an iterable containing all relevant 'work' objects""" diff --git a/test/results/pixiv.py b/test/results/pixiv.py index f06e7eab20..d26ce55c82 100644 --- a/test/results/pixiv.py +++ b/test/results/pixiv.py @@ -277,6 +277,7 @@ "#url" : "https://www.pixiv.net/en/artworks/103983466", "#comment" : "empty 'caption' in App API response (#4327, #5191)", "#class" : pixiv.PixivWorkExtractor, + "#options" : {"captions": True}, "caption": r"re:Either she doesn't know how to pose or she can't move with that much clothing on her, in any case she's very well dressed for a holiday trip around town. Lots of stuff to see and a perfect day to grab some sweet pastries at the bakery.
...", },