From 4bf43efe785e8ae0b83fea0ac0ec38b3e2a2d5b4 Mon Sep 17 00:00:00 2001 From: zotify Date: Sat, 12 Nov 2022 14:17:48 +1300 Subject: [PATCH] fix cover art resolution again --- CHANGELOG.md | 3 +++ setup.cfg | 2 +- zotify/const.py | 2 ++ zotify/track.py | 9 +++++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b83f52e..ee6a80a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.6.10 +- Fix cover art size once and for all + ## 0.6.9 - Fix low resolution cover art - Fix crash when missing ffmpeg diff --git a/setup.cfg b/setup.cfg index 3393bd5..f4d68cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = zotify -version = 0.6.9 +version = 0.6.10 author = Zotify Contributors description = A highly customizable music and podcast downloader long_description = file: README.md diff --git a/zotify/const.py b/zotify/const.py index ae63567..98f42c5 100644 --- a/zotify/const.py +++ b/zotify/const.py @@ -80,6 +80,8 @@ TYPE = 'type' PREMIUM = 'premium' +WIDTH = 'width' + USER_READ_EMAIL = 'user-read-email' PLAYLIST_READ_PRIVATE = 'playlist-read-private' diff --git a/zotify/track.py b/zotify/track.py index f82ceee..d1ef537 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -10,7 +10,7 @@ import ffmpy from zotify.const import TRACKS, ALBUM, GENRES, NAME, ITEMS, DISC_NUMBER, TRACK_NUMBER, IS_PLAYABLE, ARTISTS, IMAGES, URL, \ RELEASE_DATE, ID, TRACKS_URL, FOLLOWED_ARTISTS_URL, SAVED_TRACKS_URL, TRACK_STATS_URL, CODEC_MAP, EXT_MAP, DURATION_MS, \ - HREF, ARTISTS + HREF, ARTISTS, WIDTH from zotify.termoutput import Printer, PrintChannel from zotify.utils import fix_filename, set_audio_tags, set_music_thumbnail, create_download_directory, \ get_directory_song_ids, add_to_directory_song_ids, get_previously_downloaded, add_to_archive, fmt_seconds @@ -61,7 +61,6 @@ def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, An album_name = info[TRACKS][0][ALBUM][NAME] name = info[TRACKS][0][NAME] - image_url = info[TRACKS][0][ALBUM][IMAGES][2][URL] release_year = info[TRACKS][0][ALBUM][RELEASE_DATE].split('-')[0] disc_number = info[TRACKS][0][DISC_NUMBER] track_number = info[TRACKS][0][TRACK_NUMBER] @@ -69,6 +68,12 @@ def get_song_info(song_id) -> Tuple[List[str], List[Any], str, str, Any, Any, An is_playable = info[TRACKS][0][IS_PLAYABLE] duration_ms = info[TRACKS][0][DURATION_MS] + image = info[TRACKS][0][ALBUM][IMAGES][0] + for i in info[TRACKS][0][ALBUM][IMAGES]: + if i[WIDTH] > image[WIDTH]: + image = i + image_url = image[URL] + return artists, info[TRACKS][0][ARTISTS], album_name, name, image_url, release_year, disc_number, track_number, scraped_song_id, is_playable, duration_ms except Exception as e: raise ValueError(f'Failed to parse TRACKS_URL response: {str(e)}\n{raw}')