[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
|
Type
|
||||||
``string``
|
``string``
|
||||||
Default
|
Default
|
||||||
``"legacy"``
|
``"posts"``
|
||||||
Description
|
Description
|
||||||
API endpoint to use for retrieving creator posts.
|
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>`__
|
`/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.
|
| Provides less metadata, but is more reliable at returning all posts.
|
||||||
| Supports filtering results by ``tag`` query parameter.
|
| 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"``
|
``"posts"``
|
||||||
| Use the results from
|
| Use the results from
|
||||||
`/v1/{service}/user/{creator_id} <https://kemono.su/documentation/api#operations-Posts-get_v1__service__user__creator_id_>`__
|
`/v1/{service}/user/{creator_id} <https://kemono.su/documentation/api#operations-Posts-get_v1__service__user__creator_id_>`__
|
||||||
|
|||||||
@@ -379,7 +379,7 @@
|
|||||||
"comments" : false,
|
"comments" : false,
|
||||||
"dms" : false,
|
"dms" : false,
|
||||||
"duplicates" : false,
|
"duplicates" : false,
|
||||||
"endpoint" : "legacy",
|
"endpoint" : "posts",
|
||||||
"favorites" : "artist",
|
"favorites" : "artist",
|
||||||
"files" : ["attachments", "file", "inline"],
|
"files" : ["attachments", "file", "inline"],
|
||||||
"max-posts" : null,
|
"max-posts" : null,
|
||||||
|
|||||||
@@ -317,16 +317,26 @@ class KemonopartyUserExtractor(KemonopartyExtractor):
|
|||||||
KemonopartyExtractor.__init__(self, match)
|
KemonopartyExtractor.__init__(self, match)
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
if self.config("endpoint") == "posts":
|
endpoint = self.config("endpoint")
|
||||||
endpoint = self.api.creator_posts
|
if endpoint == "legacy":
|
||||||
else:
|
|
||||||
endpoint = self.api.creator_posts_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
|
_, _, service, creator_id, query = self.groups
|
||||||
params = text.parse_query(query)
|
params = text.parse_query(query)
|
||||||
return endpoint(service, creator_id,
|
return endpoint(service, creator_id,
|
||||||
params.get("o"), params.get("q"), params.get("tag"))
|
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):
|
class KemonopartyPostsExtractor(KemonopartyExtractor):
|
||||||
"""Extractor for kemono.su post listings"""
|
"""Extractor for kemono.su post listings"""
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ __tests__ = (
|
|||||||
"#url" : "https://kemono.su/fanbox/user/6993449",
|
"#url" : "https://kemono.su/fanbox/user/6993449",
|
||||||
"#category": ("", "kemonoparty", "fanbox"),
|
"#category": ("", "kemonoparty", "fanbox"),
|
||||||
"#class" : kemonoparty.KemonopartyUserExtractor,
|
"#class" : kemonoparty.KemonopartyUserExtractor,
|
||||||
|
"#options" : {"endpoint": "legacy"},
|
||||||
"#range" : "1-500",
|
"#range" : "1-500",
|
||||||
"#count" : 500,
|
"#count" : 500,
|
||||||
|
|
||||||
@@ -41,12 +42,12 @@ __tests__ = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://kemono.su/patreon/user/881792?o=150",
|
"#url" : "https://kemono.su/fanbox/user/6993449",
|
||||||
"#comment" : "'max-posts' and 'endpoint' option, 'o' query parameter (#1674)",
|
"#comment" : "endpoint: legacy+ (#7438 #7450 #7462)",
|
||||||
"#category": ("", "kemonoparty", "patreon"),
|
"#category": ("", "kemonoparty", "fanbox"),
|
||||||
"#class" : kemonoparty.KemonopartyUserExtractor,
|
"#class" : kemonoparty.KemonopartyUserExtractor,
|
||||||
"#options" : {"max-posts": 100, "endpoint": "posts"},
|
"#options" : {"endpoint": "legacy+"},
|
||||||
"#count" : range(200, 400),
|
"#range" : "1-10",
|
||||||
|
|
||||||
"added" : {str, None},
|
"added" : {str, None},
|
||||||
"archives" : [],
|
"archives" : [],
|
||||||
@@ -64,21 +65,49 @@ __tests__ = (
|
|||||||
"service" : "fanbox",
|
"service" : "fanbox",
|
||||||
"shared_file": False,
|
"shared_file": False,
|
||||||
"subcategory": "fanbox",
|
"subcategory": "fanbox",
|
||||||
"tags" : str,
|
"tags" : list,
|
||||||
"title" : str,
|
"title" : str,
|
||||||
"user" : "6993449",
|
"user" : "6993449",
|
||||||
"username" : "かえぬこ",
|
"username" : "かえぬこ",
|
||||||
"file" : {
|
"file" : {
|
||||||
"extension": str,
|
"hash" : "len:str:64",
|
||||||
"filename" : str,
|
"name" : str,
|
||||||
"hash" : "len:str:64",
|
"path" : str,
|
||||||
"name" : str,
|
"type" : "file",
|
||||||
"path" : str,
|
"url" : 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=お蔵入りになった",
|
"#url" : "https://kemono.su/fanbox/user/6993449?q=お蔵入りになった",
|
||||||
"#comment" : "search / 'q' query parameter (#3385, #4057)",
|
"#comment" : "search / 'q' query parameter (#3385, #4057)",
|
||||||
|
|||||||
Reference in New Issue
Block a user