Skip to content

Commit

Permalink
[hitomi] fix error when number of tag results is multiple of 25
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Aug 28, 2022
1 parent 3cebf78 commit 2eb0ddd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gallery_dl/extractor/hitomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,24 @@ def items(self):
}

offset = 0
total = None
while True:
headers["Referer"] = "{}/{}/{}.html?page={}".format(
self.root, self.type, self.tag, offset // 100 + 1)
headers["Range"] = "bytes={}-{}".format(offset, offset+99)
nozomi = self.request(nozomi_url, headers=headers).content
response = self.request(nozomi_url, headers=headers)

for gallery_id in decode_nozomi(nozomi):
for gallery_id in decode_nozomi(response.content):
gallery_url = "{}/galleries/{}.html".format(
self.root, gallery_id)
yield Message.Queue, gallery_url, data

if len(nozomi) < 100:
return
offset += 100
if total is None:
total = text.parse_int(
response.headers["content-range"].rpartition("/")[2])
if offset >= total:
return


@memcache(maxage=1800)
Expand Down

0 comments on commit 2eb0ddd

Please sign in to comment.