From 2162fa7df2875191eeadcb105f466668ff91ddc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 26 Nov 2024 23:23:39 +0100 Subject: [PATCH] [kemonoparty] fix 'comments' for posts without comments (#6415) https://github.com/mikf/gallery-dl/issues/6415#issuecomment-2501966303 --- gallery_dl/extractor/kemonoparty.py | 11 +++++++++-- test/results/kemonoparty.py | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/kemonoparty.py b/gallery_dl/extractor/kemonoparty.py index d8c44faf..e731e550 100644 --- a/gallery_dl/extractor/kemonoparty.py +++ b/gallery_dl/extractor/kemonoparty.py @@ -90,12 +90,19 @@ class KemonopartyExtractor(Extractor): post["username"] = username post["user_profile"] = profile if comments: - post["comments"] = self.api.creator_post_comments( - service, creator_id, post["id"]) + try: + post["comments"] = self.api.creator_post_comments( + service, creator_id, post["id"]) + except exception.HttpError: + post["comments"] = () if dms is not None: if dms is True: dms = self.api.creator_dms( post["service"], post["user"]) + try: + dms = dms["props"]["dms"] + except Exception: + dms = () post["dms"] = dms if announcements is not None: if announcements is True: diff --git a/test/results/kemonoparty.py b/test/results/kemonoparty.py index a9b66a88..6a388452 100644 --- a/test/results/kemonoparty.py +++ b/test/results/kemonoparty.py @@ -123,12 +123,23 @@ __tests__ = ( }, { - "#url" : "https://kemono.su/patreon/user/34134344/post/38129255", - "#comment" : "DMs (#2008)", + "#url" : "https://kemono.su/patreon/user/3161935/post/23445732", + "#comment" : "comments (#2008)", "#category": ("", "kemonoparty", "patreon"), "#class" : kemonoparty.KemonopartyPostExtractor, - "#options" : {"dms": True}, + "#options" : {"comments": True}, + "comments": "len:12", +}, + +{ + "#url" : "https://kemono.su/patreon/user/34134344/post/38129255", + "#comment" : "DMs (#2008); no comments", + "#category": ("", "kemonoparty", "patreon"), + "#class" : kemonoparty.KemonopartyPostExtractor, + "#options" : {"dms": True, "comments": True}, + + "comments": (), "dms": [ { "added" : "2021-07-31T02:47:51.327865",