[imagebam] raise 'NotFoundError' for deleted images (#8890)

This commit is contained in:
Mike Fährmann
2026-01-18 21:27:27 +01:00
parent 8a84714372
commit 8c9ca609ea
2 changed files with 11 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2014-2025 Mike Fährmann
# Copyright 2014-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
@@ -9,7 +9,7 @@
"""Extractors for https://www.imagebam.com/"""
from .common import Extractor, Message
from .. import text
from .. import text, exception
class ImagebamExtractor(Extractor):
@@ -28,6 +28,8 @@ class ImagebamExtractor(Extractor):
def _parse_image_page(self, path):
page = self.request(self.root + path).text
url, pos = text.extract(page, '<img src="https://images', '"')
if not url:
raise exception.NotFoundError("image")
filename = text.unescape(text.extract(page, 'alt="', '"', pos)[0])
return text.nameext_from_name(filename, {

View File

@@ -87,4 +87,11 @@ __tests__ = (
"url" : "https://images3.imagebam.com/d2/7a/d9/b728aa119132443.jpg",
},
{
"#url" : "https://www.imagebam.com/image/40a481151474621",
"#comment" : "deleted image (#8890)",
"#class" : imagebam.ImagebamImageExtractor,
"#exception": exception.NotFoundError,
},
)