1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[exhentai] fix 'imgkey' handling

This commit is contained in:
Mike Fährmann 2015-11-18 14:10:42 +01:00
parent 4440b40234
commit 9c63027d2c
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -94,7 +94,7 @@ class ExhentaiExtractor(Extractor):
page = self.request(url).text
data, pos = text.extract_all(page, (
(None , '<div id="i3"><a onclick="return load_image(', ''),
("imgkey" , "'", "'"),
("imgkey-next", "'", "'"),
("url" , '<img id="img" src="', '"'),
("title" , '<div id="i4"><div>', ' :: '),
("origurl" , 'http://exhentai.org/fullimg.php', '"'),
@ -102,6 +102,7 @@ class ExhentaiExtractor(Extractor):
("startkey" , 'var startkey="', '";'),
("showkey" , 'var showkey="', '";'),
))
data["imgkey"] = data["startkey"]
if data["origurl"]:
data["origurl"] = "http://exhentai.org/fullimg.php" + text.unescape(data["origurl"])
else:
@ -112,13 +113,16 @@ class ExhentaiExtractor(Extractor):
"method" : "showpage",
"page" : 2,
"gid" : int(data["gid"]),
"imgkey" : data["imgkey"],
"imgkey" : data["imgkey-next"],
"showkey": data["showkey"],
}
while True:
if data["imgkey"] == data["imgkey-next"]:
return
time.sleep(random.uniform(3, 6))
page = self.session.post(self.api_url, json=request).json()
data["imgkey"] , pos = text.extract(page["i3"], "'", "'")
data["imgkey"] = data["imgkey-next"]
data["imgkey-next"], pos = text.extract(page["i3"], "'", "'")
data["url"] , pos = text.extract(page["i3"], '<img id="img" src="', '"', pos)
data["title"] , pos = text.extract(page["i" ], '<div>', ' :: ')
data["origurl"] , pos = text.extract(page["i7"], '<a href="', '"')
@ -127,7 +131,5 @@ class ExhentaiExtractor(Extractor):
else:
data["origurl"] = data["url"]
yield data
if request["imgkey"] == data["imgkey"]:
return
request["imgkey"] = data["imgkey"]
request["imgkey"] = data["imgkey-next"]
request["page"] += 1