[kemonoparty] restore using default creator posts endpoint
(#7438 #7450 #7462)
- revert c3fb0f53ee
- add '"endpoint": "legacy+"' option
to use '/posts-legacy' results and with full metadata
This commit is contained in:
@@ -3112,7 +3112,7 @@ extractor.kemonoparty.endpoint
|
||||
Type
|
||||
``string``
|
||||
Default
|
||||
``"legacy"``
|
||||
``"posts"``
|
||||
Description
|
||||
API endpoint to use for retrieving creator posts.
|
||||
|
||||
@@ -3121,6 +3121,13 @@ Description
|
||||
`/v1/{service}/user/{creator_id}/posts-legacy <https://kemono.su/documentation/api#operations-default-get_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.
|
||||
``"legacy+"``
|
||||
| Use the results from
|
||||
`/v1/{service}/user/{creator_id}/posts-legacy <https://kemono.su/documentation/api#operations-default-get_v1__service__user__creator_id__posts_legacy>`__
|
||||
to retrieve post IDs
|
||||
| and one request to
|
||||
`/v1/{service}/user/{creator_id}/post/{post_id} <https://kemono.su/documentation/api#operations-Posts-get_v1__service__user__creator_id__post__post_id_>`__
|
||||
to get a full set of metadata for each.
|
||||
``"posts"``
|
||||
| Use the results from
|
||||
`/v1/{service}/user/{creator_id} <https://kemono.su/documentation/api#operations-Posts-get_v1__service__user__creator_id_>`__
|
||||
|
||||
@@ -379,7 +379,7 @@
|
||||
"comments" : false,
|
||||
"dms" : false,
|
||||
"duplicates" : false,
|
||||
"endpoint" : "legacy",
|
||||
"endpoint" : "posts",
|
||||
"favorites" : "artist",
|
||||
"files" : ["attachments", "file", "inline"],
|
||||
"max-posts" : null,
|
||||
|
||||
@@ -317,16 +317,26 @@ class KemonopartyUserExtractor(KemonopartyExtractor):
|
||||
KemonopartyExtractor.__init__(self, match)
|
||||
|
||||
def posts(self):
|
||||
if self.config("endpoint") == "posts":
|
||||
endpoint = self.api.creator_posts
|
||||
else:
|
||||
endpoint = self.config("endpoint")
|
||||
if endpoint == "legacy":
|
||||
endpoint = self.api.creator_posts_legacy
|
||||
elif endpoint == "legacy+":
|
||||
endpoint = self._posts_legacy_plus
|
||||
else:
|
||||
endpoint = self.api.creator_posts
|
||||
|
||||
_, _, service, creator_id, query = self.groups
|
||||
params = text.parse_query(query)
|
||||
return endpoint(service, creator_id,
|
||||
params.get("o"), params.get("q"), params.get("tag"))
|
||||
|
||||
def _posts_legacy_plus(self, service, creator_id,
|
||||
offset=0, query=None, tags=None):
|
||||
for post in self.api.creator_posts_legacy(
|
||||
service, creator_id, offset, query, tags):
|
||||
yield self.api.creator_post(
|
||||
service, creator_id, post["id"])["post"]
|
||||
|
||||
|
||||
class KemonopartyPostsExtractor(KemonopartyExtractor):
|
||||
"""Extractor for kemono.su post listings"""
|
||||
|
||||
@@ -13,6 +13,7 @@ __tests__ = (
|
||||
"#url" : "https://kemono.su/fanbox/user/6993449",
|
||||
"#category": ("", "kemonoparty", "fanbox"),
|
||||
"#class" : kemonoparty.KemonopartyUserExtractor,
|
||||
"#options" : {"endpoint": "legacy"},
|
||||
"#range" : "1-500",
|
||||
"#count" : 500,
|
||||
|
||||
@@ -41,12 +42,12 @@ __tests__ = (
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://kemono.su/patreon/user/881792?o=150",
|
||||
"#comment" : "'max-posts' and 'endpoint' option, 'o' query parameter (#1674)",
|
||||
"#category": ("", "kemonoparty", "patreon"),
|
||||
"#url" : "https://kemono.su/fanbox/user/6993449",
|
||||
"#comment" : "endpoint: legacy+ (#7438 #7450 #7462)",
|
||||
"#category": ("", "kemonoparty", "fanbox"),
|
||||
"#class" : kemonoparty.KemonopartyUserExtractor,
|
||||
"#options" : {"max-posts": 100, "endpoint": "posts"},
|
||||
"#count" : range(200, 400),
|
||||
"#options" : {"endpoint": "legacy+"},
|
||||
"#range" : "1-10",
|
||||
|
||||
"added" : {str, None},
|
||||
"archives" : [],
|
||||
@@ -64,21 +65,49 @@ __tests__ = (
|
||||
"service" : "fanbox",
|
||||
"shared_file": False,
|
||||
"subcategory": "fanbox",
|
||||
"tags" : str,
|
||||
"tags" : list,
|
||||
"title" : str,
|
||||
"user" : "6993449",
|
||||
"username" : "かえぬこ",
|
||||
"file" : {
|
||||
"extension": str,
|
||||
"filename" : str,
|
||||
"hash" : "len:str:64",
|
||||
"name" : str,
|
||||
"path" : str,
|
||||
"type" : "file",
|
||||
"url" : 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' and 'endpoint' option, 'o' query parameter (#1674)",
|
||||
"#category": ("", "kemonoparty", "patreon"),
|
||||
"#class" : kemonoparty.KemonopartyUserExtractor,
|
||||
"#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, None},
|
||||
"embed" : dict,
|
||||
"id" : str,
|
||||
"poll" : None,
|
||||
"published" : str,
|
||||
"service" : "patreon",
|
||||
"shared_file": False,
|
||||
"subcategory": "patreon",
|
||||
"tags" : {str, None},
|
||||
"title" : str,
|
||||
"user" : "881792",
|
||||
"username" : "diives",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://kemono.su/fanbox/user/6993449?q=お蔵入りになった",
|
||||
"#comment" : "search / 'q' query parameter (#3385, #4057)",
|
||||
|
||||
Reference in New Issue
Block a user