Skip to content

Commit

Permalink
[hitomi] fix 'tag' extraction (fixes #2189)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 13, 2022
1 parent df2f0c0 commit 17c9c47
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions gallery_dl/extractor/hitomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class HitomiTagExtractor(Extractor):
"""Extractor for galleries from tag searches on hitomi.la"""
category = "hitomi"
subcategory = "tag"
root = "https://hitomi.la"
pattern = (r"(?:https?://)?hitomi\.la/"
r"(tag|artist|group|series|type|character)/"
r"([^/?#]+)\.html")
Expand All @@ -183,12 +184,29 @@ def __init__(self, match):
self.tag = tag

def items(self):
url = "https://ltn.hitomi.la/{}/{}.nozomi".format(self.type, self.tag)
data = {"_extractor": HitomiGalleryExtractor}
nozomi_url = "https://ltn.hitomi.la/{}/{}.nozomi".format(
self.type, self.tag)
headers = {
"Origin": self.root,
"Cache-Control": "max-age=0",
}

for gallery_id in decode_nozomi(self.request(url).content):
url = "https://hitomi.la/galleries/{}.html".format(gallery_id)
yield Message.Queue, url, data
offset = 0
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

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

if len(nozomi) < 100:
return
offset += 100


@memcache()
Expand Down

0 comments on commit 17c9c47

Please sign in to comment.