[hitomi] update '_parse_gg()'

This commit is contained in:
Mike Fährmann
2022-01-01 17:54:30 +01:00
parent 3b7c7daa76
commit 1e0278702d

View File

@@ -26,7 +26,7 @@ class HitomiGalleryExtractor(GalleryExtractor):
r"/(?:[^/?#]+-)?(\d+)")
test = (
("https://hitomi.la/galleries/867789.html", {
"pattern": r"https://[a-c]b.hitomi.la/images/1639745412/\d+"
"pattern": r"https://[a-c]b.hitomi.la/images/1641047429/\d+"
r"/[0-9a-f]{64}\.jpg",
"keyword": "4873ef9a523621fc857b114e0b2820ba4066e9ae",
"options": (("metadata", True),),
@@ -39,12 +39,12 @@ class HitomiGalleryExtractor(GalleryExtractor):
}),
# Game CG with scenes (#321)
("https://hitomi.la/galleries/733697.html", {
"url": "479d16fe92117a6a2ce81b4e702e6347922c81e3",
"url": "7f5cfcb52d084bd3a65384aaf30daa9bbee8030f",
"count": 210,
}),
# fallback for galleries only available through /reader/ URLs
("https://hitomi.la/galleries/1045954.html", {
"url": "ebc1415c5d7f634166ef7e2635b77735de1ea7a2",
"url": "7f5c37d2cb54194b50a3e52ed5aa5022fba64b56",
"count": 1413,
}),
# gallery with "broken" redirect
@@ -148,7 +148,7 @@ class HitomiGalleryExtractor(GalleryExtractor):
# see https://ltn.hitomi.la/common.js
inum = int(ihash[-1] + ihash[-3:-1], 16)
url = "https://{}b.hitomi.la/images/{}/{}/{}.{}".format(
chr(97 + gg_m.get(inum, 0)),
chr(97 + gg_m.get(inum, 1)),
gg_b, inum, ihash, idata["extension"],
)
result.append((url, idata))
@@ -196,8 +196,9 @@ def _parse_gg(extr):
page = extr.request("https://ltn.hitomi.la/gg.js").text
m = {
int(match.group(1)): int(match.group(2))
for match in re.finditer(r"case (\d+): o = (\d+); break;", page)
int(match.group(1)): int(match.group(2) or 0)
for match in re.finditer(
r"case\s+(\d+):(?:\s*o\s*=\s*(\d+))?", page)
}
b = re.search(r"b:\s*[\"'](.+)[\"']", page)