From ef685ecb42023d2fe477a62d85aad0c4343c928c Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 13 Feb 2023 11:55:47 +0700 Subject: [PATCH] handle PIL error empty thumbnail image, #425 --- tubearchivist/home/src/download/thumbnails.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/download/thumbnails.py b/tubearchivist/home/src/download/thumbnails.py index e91a97db..7b71f915 100644 --- a/tubearchivist/home/src/download/thumbnails.py +++ b/tubearchivist/home/src/download/thumbnails.py @@ -43,7 +43,11 @@ class ThumbManagerBase: response = requests.get(url, stream=True, timeout=5) if response.ok: try: - return Image.open(response.raw) + img = Image.open(response.raw) + if isinstance(img, Image.Image): + return img + return self.get_fallback() + except UnidentifiedImageError: print(f"failed to open thumbnail: {url}") return self.get_fallback()