[imagetwist] detect removed images (#8415)

This commit is contained in:
Mike Fährmann
2025-10-15 10:26:54 +02:00
parent 43448f7089
commit d44a0f8094
2 changed files with 12 additions and 0 deletions

View File

@@ -53,6 +53,8 @@ class ImagehostImageExtractor(Extractor):
).text
url, filename = self.get_info(page)
if not url:
return
data = text.nameext_from_url(filename, {"token": self.token})
data.update(self.metadata(page))
if self._https and url.startswith("http:"):
@@ -199,6 +201,8 @@ class ImagetwistImageExtractor(ImagehostImageExtractor):
def get_info(self, page):
url , pos = text.extract(page, '<img src="', '"')
if url and url.startswith("/imgs/"):
return None, None
filename, pos = text.extract(page, ' alt="', '"', pos)
return url, filename

View File

@@ -41,6 +41,14 @@ __tests__ = (
"#class" : imagehosts.ImagetwistImageExtractor,
},
{
"#url" : "https://imagetwist.com/tynhxt4ay9rl/9g09tq0e2i1b.jpg",
"#comment" : "'Image not found' (#8415)",
"#category": ("imagehost", "imagetwist", "image"),
"#class" : imagehosts.ImagetwistImageExtractor,
"#count" : 0,
},
{
"#url" : "https://imagetwist.com/p/gdldev/747223/digits",
"#category": ("imagehost", "imagetwist", "gallery"),