Skip to content

Commit

Permalink
Fixing check for the length of response:
Browse files Browse the repository at this point in the history
1. If it is list - just check len
2. If there is a key - check that the key length is less then the batch.
  • Loading branch information
BishopRed90 committed Jan 15, 2025
1 parent 293b594 commit 6b29ed1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions gallery_dl/extractor/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,14 +568,19 @@ def _call(self, endpoint, params=None):
response = self.extractor.request(url, params=params)
return response.json()

def _pagination(self, endpoint, params, batch=50, key=None):
def _pagination(self, endpoint, params, batch=50, key=False):
offset = text.parse_int(params.get("o"))
params["o"] = offset - offset % batch

while True:
data = self._call(endpoint, params)
yield from data.get(key, data)
if len(data.get(key, data)) < batch:
return
if key:
yield from data.get(key)
if len(data.get(key)) < batch:
return
else:
yield from data
if len(data) < batch:
return

params["o"] += batch

0 comments on commit 6b29ed1

Please sign in to comment.