From 9cce4616271715093f1a885ebfb64be6dabd2abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 26 Mar 2024 15:20:14 +0100 Subject: [PATCH] [kemonoparty] add 'announcements' option (#5262) https://github.com/mikf/gallery-dl/issues/5262#issuecomment-2015919188 --- docs/configuration.rst | 10 ++++++++++ gallery_dl/extractor/kemonoparty.py | 30 +++++++++++++++++------------ test/results/kemonoparty.py | 13 +++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 51408d3c90..3052385f71 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2317,6 +2317,16 @@ Description Extract a user's direct messages as ``dms`` metadata. +extractor.kemonoparty.announcements +----------------------------------- +Type + ``bool`` +Default + ``false`` +Description + Extract a user's announcements as ``announcements`` metadata. + + extractor.kemonoparty.favorites ------------------------------- Type diff --git a/gallery_dl/extractor/kemonoparty.py b/gallery_dl/extractor/kemonoparty.py index f7f5ea9d11..bb0b03af93 100644 --- a/gallery_dl/extractor/kemonoparty.py +++ b/gallery_dl/extractor/kemonoparty.py @@ -57,7 +57,7 @@ def items(self): generators = self._build_file_generators(self.config("files")) duplicates = self.config("duplicates") comments = self.config("comments") - username = dms = None + username = dms = announcements = None # prevent files from being sent with gzip compression headers = {"Accept-Encoding": "identity"} @@ -68,6 +68,8 @@ def items(self): '"): - footer = text.extr(dm, "") - dms.append({ + cards = [] + for card in text.extract_iter(page, ""): + footer = text.extr(card, "") + cards.append({ "body": text.unescape(text.extr( - dm, "
", "
", " 19: diff --git a/test/results/kemonoparty.py b/test/results/kemonoparty.py index 7b8d1301c8..4c37008979 100644 --- a/test/results/kemonoparty.py +++ b/test/results/kemonoparty.py @@ -135,6 +135,19 @@ }], }, +{ + "#url" : "https://kemono.su/patreon/user/3161935/post/68231671", + "#comment" : "announcements", + "#category": ("", "kemonoparty", "patreon"), + "#class" : kemonoparty.KemonopartyPostExtractor, + "#options" : {"announcements": True}, + + "announcements": [{ + "body": "
Thank you so much for the support!
This Patreon is more of a tip jar for supporting what I make. I have to clarify that there are no exclusive Patreon animations because all are released for the public. You will get earlier access to WIPs. Direct downloads to my works are also available for $5 and $10 Tiers.
", + "date": "2023-02", + }], +}, + { "#url" : "https://kemono.su/patreon/user/19623797/post/29035449", "#comment" : "invalid file (#3510)",