1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-21 18:22:30 +01:00

[pixiv] add 'captions' option (#4327)

make extra requests for empty captions independent of 'sanity'
This commit is contained in:
Mike Fährmann 2024-10-22 16:31:37 +02:00
parent 2d15e64ea9
commit 33161da121
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -38,6 +38,7 @@ class PixivExtractor(Extractor):
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 @@ class PixivExtractor(Extractor):
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 @@ class PixivExtractor(Extractor):
"x_restrict" : 0,
}
def _web_to_mobile(self, work):
return work
def works(self):
"""Return an iterable containing all relevant 'work' objects"""

View File

@ -277,6 +277,7 @@ __tests__ = (
"#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.<br />...",
},