extract original thumbnail image

This commit is contained in:
mungai-njoroge
2023-07-06 13:52:32 +03:00
parent 6ef3cc3545
commit 65d21d07da
10 changed files with 47 additions and 27 deletions
-1
View File
@@ -241,7 +241,6 @@ def save_similar_artists(artist: Artist):
if len(artist_.similar_artist_hashes) == 0:
return
print(artist.artisthash, artist.name)
lastfmdb.insert_one(artist_)
-1
View File
@@ -140,7 +140,6 @@ def get_titles(items: _type):
text = item.og_title
elif isinstance(item, models.Album):
text = item.title
# print(text)
elif isinstance(item, models.Artist):
text = item.name
else:
+6 -4
View File
@@ -28,18 +28,20 @@ def extract_thumb(filepath: str, webp_path: str) -> bool:
"""
Extracts the thumbnail from an audio file. Returns the path to the thumbnail.
"""
img_path = os.path.join(Paths.get_lg_thumb_path(), webp_path)
original_img_path = os.path.join(Paths.get_original_thumb_path(), webp_path)
lg_img_path = os.path.join(Paths.get_lg_thumb_path(), webp_path)
sm_img_path = os.path.join(Paths.get_sm_thumb_path(), webp_path)
tsize = Defaults.THUMB_SIZE
sm_tsize = Defaults.SM_THUMB_SIZE
def save_image(img: Image.Image):
img.save(original_img_path, "webp")
img.resize((tsize, tsize), Image.ANTIALIAS).save(lg_img_path, "webp")
img.resize((sm_tsize, sm_tsize), Image.ANTIALIAS).save(sm_img_path, "webp")
img.resize((tsize, tsize), Image.ANTIALIAS).save(img_path, "webp")
if os.path.exists(img_path):
img_size = os.path.getsize(img_path)
if os.path.exists(lg_img_path):
img_size = os.path.getsize(lg_img_path)
if img_size > 0:
return True