[imhentai] prevent exceptions for galleries without image data (#8951)

This commit is contained in:
Mike Fährmann
2026-01-28 10:40:22 +01:00
parent 6c9dff1e29
commit aa8610c11c
2 changed files with 29 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Mike Fährmann
# Copyright 2025-2026 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -123,7 +123,11 @@ class ImhentaiGalleryExtractor(ImhentaiExtractor, GalleryExtractor):
return results
def images(self, page):
data = util.json_loads(text.extr(page, "$.parseJSON('", "'"))
try:
data = util.json_loads(text.extr(page, "$.parseJSON('", "'"))
except Exception:
self.log.warning("%s: Missing image data", self.gallery_id)
return ()
base = text.extr(page, 'data-src="', '"').rpartition("/")[0] + "/"
exts = {"j": "jpg", "p": "png", "g": "gif", "w": "webp", "a": "avif"}

View File

@@ -109,12 +109,34 @@ __tests__ = (
],
},
{
"#url" : "https://hentaienvy.com/gallery/1119432/",
"#comment" : "empty 'var g_th = $.parseJSON('');' (#8951)",
"#category": ("IMHentai", "hentaienvy", "gallery"),
"#class" : imhentai.ImhentaiGalleryExtractor,
"#metadata": "post",
"#count" : 0,
"#log" : "1119432: Missing image data",
"artist" : [],
"character" : [],
"gallery_id": 1119432,
"group" : [],
"lang" : "ja",
"language" : ["japanese"],
"parody" : ["super mario brothers"],
"tags" : list,
"title" : "hentai girls",
"title_alt" : "",
"type" : "western",
},
{
"#url" : "https://hentaienvy.com/artist/asutora/",
"#category": ("IMHentai", "hentaienvy", "tag"),
"#class" : imhentai.ImhentaiTagExtractor,
"#pattern" : imhentai.ImhentaiGalleryExtractor.pattern,
"#count" : range(45, 50),
"#count" : range(45, 60),
},
{