diff --git a/app/lib/artistlib.py b/app/lib/artistlib.py index 1c9bfd9..4777d41 100644 --- a/app/lib/artistlib.py +++ b/app/lib/artistlib.py @@ -5,7 +5,7 @@ from io import BytesIO from pathlib import Path import requests -from PIL import Image, UnidentifiedImageError +from PIL import Image, PngImagePlugin, UnidentifiedImageError from requests.exceptions import ConnectionError as RequestConnectionError from requests.exceptions import ReadTimeout @@ -15,9 +15,12 @@ from app.store import artists as artist_store from app.utils.hashing import create_hash from app.utils.progressbar import tqdm - CHECK_ARTIST_IMAGES_KEY = "" +LARGE_ENOUGH_NUMBER = 100 +PngImagePlugin.MAX_TEXT_CHUNK = LARGE_ENOUGH_NUMBER * (1024**2) +# https://stackoverflow.com/a/61466412 + def get_artist_image_link(artist: str): """ @@ -36,7 +39,7 @@ def get_artist_image_link(artist: str): artist_hash = create_hash(artist, decode=True) if res_hash == artist_hash: - return res["picture_big"] + return str(res["picture_big"]).removesuffix(".jpg") + ".png" return None except (RequestConnectionError, ReadTimeout, IndexError, KeyError): diff --git a/app/lib/populate.py b/app/lib/populate.py index 57076ae..95d6109 100644 --- a/app/lib/populate.py +++ b/app/lib/populate.py @@ -263,18 +263,16 @@ class ProcessTrackThumbnails: # process the rest key_album_map = ((instance_key, album) for album in albums) - # with ThreadPoolExecutor(max_workers=CPU_COUNT) as executor: - # results = list( - # tqdm( - # executor.map(get_image, key_album_map), - # total=len(albums), - # desc="Extracting track images", - # ) - # ) + with ThreadPoolExecutor(max_workers=CPU_COUNT) as executor: + results = list( + tqdm( + executor.map(get_image, key_album_map), + total=len(albums), + desc="Extracting track images", + ) + ) - # list(results) - for album in key_album_map: - get_image(album) + list(results) def save_similar_artists(_map: tuple[str, Artist]): diff --git a/app/lib/taglib.py b/app/lib/taglib.py index ea6411a..4083bf4 100644 --- a/app/lib/taglib.py +++ b/app/lib/taglib.py @@ -56,7 +56,6 @@ def extract_thumb(filepath: str, webp_path: str, overwrite=False) -> bool: album_art = parse_album_art(filepath) if album_art is not None: - print("Reading image: " + filepath) try: img = Image.open(BytesIO(album_art)) except (UnidentifiedImageError, OSError):