Skip to content

Commit

Permalink
[pixiv] add 'captions' option (#4327)
Browse files Browse the repository at this point in the history
make extra requests for empty captions independent of 'sanity'
  • Loading branch information
mikf committed Oct 22, 2024
1 parent 2d15e64 commit 33161da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 11 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions gallery_dl/extractor/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"""

Expand Down
1 change: 1 addition & 0 deletions test/results/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br />...",
},
Expand Down

0 comments on commit 33161da

Please sign in to comment.