Skip to content

Commit

Permalink
[kemonoparty] parse 'o' query parameters (#1674)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 9, 2021
1 parent 8b03677 commit d287d2e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gallery_dl/extractor/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,30 @@ def items(self):
class KemonopartyUserExtractor(KemonopartyExtractor):
"""Extractor for all posts from a kemono.party user listing"""
subcategory = "user"
pattern = BASE_PATTERN + r"/?(?:$|[?#])"
pattern = BASE_PATTERN + r"/?(?:\?o=(\d+))?(?:$|[?#])"
test = (
("https://kemono.party/fanbox/user/6993449", {
"range": "1-25",
"count": 25,
}),
# 'max-posts' option, 'o' query parameter (#1674)
("https://kemono.party/patreon/user/881792?o=150", {
"options": (("max-posts", 25),),
"count": "< 100",
}),
("https://kemono.party/subscribestar/user/alcorart"),
)

def __init__(self, match):
KemonopartyExtractor.__init__(self, match)
service, user_id = match.groups()
service, user_id, offset = match.groups()
self.api_url = "{}/api/{}/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": 0}
params = {"o": self.offset}

while True:
posts = self.request(url, params=params).json()
Expand Down

0 comments on commit d287d2e

Please sign in to comment.