diff --git a/gallery_dl/extractor/pixiv.py b/gallery_dl/extractor/pixiv.py index 7fe88690..8a4905d3 100644 --- a/gallery_dl/extractor/pixiv.py +++ b/gallery_dl/extractor/pixiv.py @@ -71,9 +71,12 @@ class PixivExtractor(Extractor): if self.meta_user: work.update(self.api.user_detail(work["user"]["id"])) if self.meta_comments: - if work["total_comments"]: - work["comments"] = list( - self.api.illust_comments(work["id"])) + if work["total_comments"] and not work.get("_ajax"): + try: + work["comments"] = list( + self.api.illust_comments(work["id"])) + except Exception: + work["comments"] = () else: work["comments"] = () if self.meta_bookmark and work["is_bookmarked"]: diff --git a/test/results/pixiv.py b/test/results/pixiv.py index 00a8a673..26041137 100644 --- a/test/results/pixiv.py +++ b/test/results/pixiv.py @@ -200,11 +200,12 @@ __tests__ = ( "#url" : "https://www.pixiv.net/en/artworks/102932581", "#comment" : "limit_sanity_level_360.png (#4327, #5180)", "#class" : pixiv.PixivWorkExtractor, - "#options" : {"sanity": True}, + "#options" : {"sanity": True, "comments": True}, "#urls" : "https://i.pximg.net/img-original/img/2022/11/20/00/00/49/102932581_p0.jpg", "caption" : "Meet a deer .", "comment_access_control": 0, + "comments" : (), "create_date" : "2022-11-19T15:00:00+00:00", "date" : "dt:2022-11-19 15:00:00", "date_url" : "dt:2022-11-19 15:00:49",