mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
delete thumbnails with 0 bytes size
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user