mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[pixiv] add 'captions' option (#4327)
make extra requests for empty captions independent of 'sanity'
This commit is contained in:
parent
2d15e64ea9
commit
33161da121
@ -3520,6 +3520,17 @@ Description
|
|||||||
Note: This requires 1 additional API request per bookmarked post.
|
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
|
extractor.pixiv.comments
|
||||||
------------------------
|
------------------------
|
||||||
Type
|
Type
|
||||||
|
@ -38,6 +38,7 @@ class PixivExtractor(Extractor):
|
|||||||
self.meta_user = self.config("metadata")
|
self.meta_user = self.config("metadata")
|
||||||
self.meta_bookmark = self.config("metadata-bookmark")
|
self.meta_bookmark = self.config("metadata-bookmark")
|
||||||
self.meta_comments = self.config("comments")
|
self.meta_comments = self.config("comments")
|
||||||
|
self.meta_captions = self.config("captions")
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
tags = self.config("tags", "japanese")
|
tags = self.config("tags", "japanese")
|
||||||
@ -76,7 +77,7 @@ class PixivExtractor(Extractor):
|
|||||||
detail = self.api.illust_bookmark_detail(work["id"])
|
detail = self.api.illust_bookmark_detail(work["id"])
|
||||||
work["tags_bookmark"] = [tag["name"] for tag in detail["tags"]
|
work["tags_bookmark"] = [tag["name"] for tag in detail["tags"]
|
||||||
if tag["is_registered"]]
|
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"):
|
not work.get("_mypixiv") and not work.get("_ajax"):
|
||||||
body = self._request_ajax("/illust/" + str(work["id"]))
|
body = self._request_ajax("/illust/" + str(work["id"]))
|
||||||
if body:
|
if body:
|
||||||
@ -294,9 +295,6 @@ class PixivExtractor(Extractor):
|
|||||||
"x_restrict" : 0,
|
"x_restrict" : 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _web_to_mobile(self, work):
|
|
||||||
return work
|
|
||||||
|
|
||||||
def works(self):
|
def works(self):
|
||||||
"""Return an iterable containing all relevant 'work' objects"""
|
"""Return an iterable containing all relevant 'work' objects"""
|
||||||
|
|
||||||
|
@ -277,6 +277,7 @@ __tests__ = (
|
|||||||
"#url" : "https://www.pixiv.net/en/artworks/103983466",
|
"#url" : "https://www.pixiv.net/en/artworks/103983466",
|
||||||
"#comment" : "empty 'caption' in App API response (#4327, #5191)",
|
"#comment" : "empty 'caption' in App API response (#4327, #5191)",
|
||||||
"#class" : pixiv.PixivWorkExtractor,
|
"#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 />...",
|
"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 />...",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user