Skip to content

Commit

Permalink
[pixiv] retrieve 'caption' from AJAX API when empty (#4327, #5191)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 9, 2024
1 parent 4adb1df commit e05b9b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gallery_dl/extractor/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ 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"):
body = self._request_ajax("/illust/" + str(work["id"]))
work["caption"] = text.unescape(body["illustComment"])

if transform_tags:
transform_tags(work)
Expand Down Expand Up @@ -180,7 +183,6 @@ def _extract_ajax(self, work, body):
for key_app, key_ajax in (
("title" , "illustTitle"),
("image_urls" , "urls"),
("caption" , "illustComment"),
("create_date" , "createDate"),
("width" , "width"),
("height" , "height"),
Expand Down Expand Up @@ -212,6 +214,7 @@ def _extract_ajax(self, work, body):
translated_name = None
tags.append({"name": name, "translated_name": translated_name})

work["caption"] = text.unescape(body["illustComment"])
work["page_count"] = count = body["pageCount"]
if count == 1:
return ({"url": url},)
Expand Down
8 changes: 8 additions & 0 deletions test/results/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@
],
},

{
"#url" : "https://www.pixiv.net/en/artworks/103983466",
"#comment" : "empty 'caption' in App API response (#4327, #5191)",
"#class" : pixiv.PixivWorkExtractor,

"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 />...",
},

{
"#url" : "https://www.pixiv.net/en/artworks/966412",
"#category": ("", "pixiv", "work"),
Expand Down

0 comments on commit e05b9b1

Please sign in to comment.