diff --git a/docs/configuration.rst b/docs/configuration.rst index 6263ca63..c1c6fb8e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3107,12 +3107,32 @@ Description Extract a user's announcements as ``announcements`` metadata. +extractor.kemonoparty.endpoint +------------------------------ +Type + ``string`` +Default + ``"legacy"`` +Description + API endpoint to use for retrieving creator posts. + + ``"legacy"`` + | Use the results from + `/v1/{service}/user/{creator_id}/posts-legacy `__ + | Provides less metadata, but is more reliable at returning all posts. + | Supports filtering results by ``tag`` query parameter. + ``"posts"`` + | Use the results from + `/v1/{service}/user/{creator_id} `__ + | Provides more metadata, but might not return a creator's first/last posts. + + extractor.kemonoparty.favorites ------------------------------- Type ``string`` Default - ``artist`` + ``"artist"`` Description Determines the type of favorites to be downloaded. diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index b8b46d63..d7cad866 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -379,6 +379,7 @@ "comments" : false, "dms" : false, "duplicates" : false, + "endpoint" : "legacy", "favorites" : "artist", "files" : ["attachments", "file", "inline"], "max-posts" : null, diff --git a/gallery_dl/extractor/kemonoparty.py b/gallery_dl/extractor/kemonoparty.py index 79070ee3..3451e5be 100644 --- a/gallery_dl/extractor/kemonoparty.py +++ b/gallery_dl/extractor/kemonoparty.py @@ -317,11 +317,15 @@ class KemonopartyUserExtractor(KemonopartyExtractor): KemonopartyExtractor.__init__(self, match) def posts(self): + if self.config("endpoint") == "posts": + endpoint = self.api.creator_posts + else: + endpoint = self.api.creator_posts_legacy + _, _, service, creator_id, query = self.groups params = text.parse_query(query) - return self.api.creator_posts_legacy( - service, creator_id, - params.get("o"), params.get("q"), params.get("tag")) + return endpoint(service, creator_id, + params.get("o"), params.get("q"), params.get("tag")) class KemonopartyPostsExtractor(KemonopartyExtractor): @@ -525,9 +529,10 @@ class KemonoAPI(): endpoint = "/file/" + file_hash return self._call(endpoint) - def creator_posts(self, service, creator_id, offset=0, query=None): + def creator_posts(self, service, creator_id, + offset=0, query=None, tags=None): endpoint = "/{}/user/{}".format(service, creator_id) - params = {"q": query, "o": offset} + params = {"q": query, "tag": tags, "o": offset} return self._pagination(endpoint, params, 50) def creator_posts_legacy(self, service, creator_id, diff --git a/test/results/kemonoparty.py b/test/results/kemonoparty.py index fc6c5fc8..1fb8ac84 100644 --- a/test/results/kemonoparty.py +++ b/test/results/kemonoparty.py @@ -15,15 +15,68 @@ __tests__ = ( "#class" : kemonoparty.KemonopartyUserExtractor, "#range" : "1-500", "#count" : 500, + + "archives" : list, + "attachments": list, + "count" : int, + "num" : int, + "date" : "type:datetime", + "id" : str, + "published" : str, + "service" : "fanbox", + "subcategory": "fanbox", + "substring" : str, + "title" : str, + "user" : "6993449", + "username" : "かえぬこ", + "file" : { + "extension": str, + "filename" : str, + "hash" : "len:str:64", + "name" : str, + "path" : str, + "type" : "file", + "url" : str, + }, }, { "#url" : "https://kemono.su/patreon/user/881792?o=150", - "#comment" : "'max-posts' option, 'o' query parameter (#1674)", + "#comment" : "'max-posts' and 'endpoint' option, 'o' query parameter (#1674)", "#category": ("", "kemonoparty", "patreon"), "#class" : kemonoparty.KemonopartyUserExtractor, - "#options" : {"max-posts": 100}, + "#options" : {"max-posts": 100, "endpoint": "posts"}, "#count" : range(200, 400), + + "added" : {str, None}, + "archives" : [], + "attachments": list, + "captions" : None, + "content" : str, + "count" : int, + "num" : int, + "date" : "type:datetime", + "edited" : str, + "embed" : dict, + "id" : str, + "poll" : None, + "published" : str, + "service" : "fanbox", + "shared_file": False, + "subcategory": "fanbox", + "tags" : str, + "title" : str, + "user" : "6993449", + "username" : "かえぬこ", + "file" : { + "extension": str, + "filename" : str, + "hash" : "len:str:64", + "name" : str, + "path" : str, + "type" : "file", + "url" : str, + }, }, { @@ -76,7 +129,7 @@ __tests__ = ( "#pattern" : r"https://kemono.su/data/21/0f/210f35388e28bbcf756db18dd516e2d82ce75[0-9a-f]+\.jpg", "#sha1_content": "900949cefc97ab8dc1979cc3664785aac5ba70dd", - "added" : "2020-05-06T20:28:02.302000", + "added" : None, "archives" : [], "content" : str, "count" : 1,