From a64dd372d2d15bce30d38f448fafa82de45a58ea Mon Sep 17 00:00:00 2001 From: RemixDev Date: Thu, 16 Apr 2020 12:09:20 +0200 Subject: [PATCH] Fixed cover caching for compilations --- deemix/app/downloader.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index 5ea6982..b44560f 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -467,7 +467,10 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None track['selectedFilesize'] = filesize track['dateString'] = formatDate(track['date'], settings['dateFormat']) if settings['tags']['savePlaylistAsCompilation'] and "_EXTRA_PLAYLIST" in trackAPI: - track['album']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_small'].replace("56x56", f"{settings['embeddedArtworkSize']}x{settings['embeddedArtworkSize']}")[:-24]+f"-{'none-100-0-0.png' if settings['PNGcovers'] else '000000-'+settings["jpegImageQuality"]+'-0-0.jpg'}" + if 'dzcdn.net'in trackAPI["_EXTRA_PLAYLIST"]['picture_small']: + track['album']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_small'][:-24]+"/{}x{}-{}".format(track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'], 'none-100-0-0.png' if settings['PNGcovers'] else f'000000-{settings["jpegImageQuality"]}-0-0.jpg') + else: + track['album']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_xl'] track['album']['title'] = trackAPI["_EXTRA_PLAYLIST"]['title'] track['album']['mainArtist'] = { 'id': trackAPI["_EXTRA_PLAYLIST"]['various_artist']['id'], @@ -536,7 +539,10 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None result['cancel'] = True return result # Download and cache coverart - track['album']['picPath'] = os.path.join(TEMPDIR, f"alb{track['album']['id']}_{settings['embeddedArtworkSize']}.{'png' if settings['PNGcovers'] else 'jpg'}") + if settings['tags']['savePlaylistAsCompilation'] and "_EXTRA_PLAYLIST" in trackAPI: + track['album']['picPath'] = os.path.join(TEMPDIR, f"pl{trackAPI['_EXTRA_PLAYLIST']['id']}_{settings['embeddedArtworkSize']}.{'png' if settings['PNGcovers'] else 'jpg'}") + else: + track['album']['picPath'] = os.path.join(TEMPDIR, f"alb{track['album']['id']}_{settings['embeddedArtworkSize']}.{'png' if settings['PNGcovers'] else 'jpg'}") track['album']['picPath'] = downloadImage(track['album']['picUrl'], track['album']['picPath']) if os.path.sep in filename: