diff --git a/server/app/lib/albumslib.py b/server/app/lib/albumslib.py index eea60e4f..6e196523 100644 --- a/server/app/lib/albumslib.py +++ b/server/app/lib/albumslib.py @@ -37,7 +37,6 @@ class RipAlbumImage: class ValidateAlbumThumbs: - @staticmethod def remove_obsolete(): """ @@ -54,6 +53,10 @@ class ValidateAlbumThumbs: if e is None: os.remove(entry.path) + break + + if os.path.getsize(entry.path) == 0: + os.remove(entry.path) @staticmethod def find_lost_thumbnails(): @@ -61,9 +64,7 @@ class ValidateAlbumThumbs: Re-rip lost album thumbnails """ entries = os.scandir(THUMBS_PATH) - entries = [ - Thumbnail(entry.name) for entry in entries if entry.is_file() - ] + entries = [Thumbnail(entry.name) for entry in entries if entry.is_file()] albums = helpers.Get.get_all_albums() thumbs = [(album.hash + ".webp") for album in albums] diff --git a/server/app/lib/taglib.py b/server/app/lib/taglib.py index 4770035d..8cd6280e 100644 --- a/server/app/lib/taglib.py +++ b/server/app/lib/taglib.py @@ -9,7 +9,7 @@ from mutagen.id3 import ID3 from PIL import Image -def return_album_art(filepath: str): +def parse_album_art(filepath: str): """ Returns the album art for a given audio file. """ @@ -36,9 +36,12 @@ def extract_thumb(filepath: str, webp_path: str) -> bool: tsize = settings.THUMB_SIZE if os.path.exists(img_path): - return True + img_size = os.path.getsize(filepath) - album_art = return_album_art(filepath) + if img_size > 0: + return True + + album_art = parse_album_art(filepath) if album_art is not None: img = Image.open(BytesIO(album_art))