[kemonoparty] support post searches (#3385, #4057)

This commit is contained in:
Mike Fährmann
2023-10-19 23:06:06 +02:00
parent aaf539009b
commit 6e830ffc9e
2 changed files with 17 additions and 4 deletions

View File

@@ -224,21 +224,21 @@ def _validate(response):
class KemonopartyUserExtractor(KemonopartyExtractor):
"""Extractor for all posts from a kemono.party user listing"""
subcategory = "user"
pattern = USER_PATTERN + r"/?(?:\?o=(\d+))?(?:$|[?#])"
pattern = USER_PATTERN + r"/?(?:\?([^#]+))?(?:$|[?#])"
example = "https://kemono.party/SERVICE/user/12345"
def __init__(self, match):
_, _, service, user_id, offset = match.groups()
_, _, service, user_id, self.query = match.groups()
self.subcategory = service
KemonopartyExtractor.__init__(self, match)
self.api_url = "{}/api/v1/{}/user/{}".format(
self.root, service, user_id)
self.user_url = "{}/{}/user/{}".format(self.root, service, user_id)
self.offset = text.parse_int(offset)
def posts(self):
url = self.api_url
params = {"o": self.offset}
params = text.parse_query(self.query)
params["o"] = text.parse_int(params.get("o"))
while True:
posts = self.request(url, params=params).json()