[imhentai] use alternate strategy for galleries without image data (#8951)
This commit is contained in:
@@ -123,18 +123,29 @@ class ImhentaiGalleryExtractor(ImhentaiExtractor, GalleryExtractor):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def images(self, page):
|
def images(self, page):
|
||||||
|
base = text.extr(page, 'data-src="', '"').rpartition("/")[0] + "/"
|
||||||
|
exts = {"j": "jpg", "p": "png", "g": "gif", "w": "webp", "a": "avif"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = util.json_loads(text.extr(page, "$.parseJSON('", "'"))
|
data = util.json_loads(text.extr(page, "$.parseJSON('", "'"))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
data = None
|
||||||
|
|
||||||
|
if data is None:
|
||||||
self.log.warning("%s: Missing image data", self.gallery_id)
|
self.log.warning("%s: Missing image data", self.gallery_id)
|
||||||
return ()
|
|
||||||
base = text.extr(page, 'data-src="', '"').rpartition("/")[0] + "/"
|
def _fallback_exts(i):
|
||||||
exts = {"j": "jpg", "p": "png", "g": "gif", "w": "webp", "a": "avif"}
|
for ext in util.advance(exts.values(), 1):
|
||||||
|
yield f"{base}{i}.{ext}"
|
||||||
|
cnt = text.parse_int(text.extr(
|
||||||
|
page, 'id="load_pages" value="', '"'))
|
||||||
|
return [(f"{base}{i}.jpg", {"_fallback": _fallback_exts(i)})
|
||||||
|
for i in range(1, cnt+1)]
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for i in map(str, range(1, len(data)+1)):
|
for i in map(str, range(1, len(data)+1)):
|
||||||
ext, width, height = data[i].split(",")
|
ext, width, height = data[i].split(",")
|
||||||
url = base + i + "." + exts[ext]
|
url = f"{base}{i}.{exts[ext]}"
|
||||||
results.append((url, {
|
results.append((url, {
|
||||||
"width" : text.parse_int(width),
|
"width" : text.parse_int(width),
|
||||||
"height": text.parse_int(height),
|
"height": text.parse_int(height),
|
||||||
|
|||||||
Reference in New Issue
Block a user