Replaced PNGcovers with localArtworkFormat
Forced embedded artwork to jpg as png artwork is buggy localArtworkFormat is a comma separated list of the local cover formats you want
This commit is contained in:
parent
492b1dbc23
commit
2dfedcb18f
|
@ -28,11 +28,11 @@
|
||||||
"syncedLyrics": false,
|
"syncedLyrics": false,
|
||||||
"embeddedArtworkSize": 800,
|
"embeddedArtworkSize": 800,
|
||||||
"localArtworkSize": 1400,
|
"localArtworkSize": 1400,
|
||||||
|
"localArtworkFormat": "jpg",
|
||||||
"saveArtwork": true,
|
"saveArtwork": true,
|
||||||
"coverImageTemplate": "cover",
|
"coverImageTemplate": "cover",
|
||||||
"saveArtworkArtist": false,
|
"saveArtworkArtist": false,
|
||||||
"artistImageTemplate": "folder",
|
"artistImageTemplate": "folder",
|
||||||
"PNGcovers": false,
|
|
||||||
"jpegImageQuality": 80,
|
"jpegImageQuality": 80,
|
||||||
"dateFormat": "Y-M-D",
|
"dateFormat": "Y-M-D",
|
||||||
"albumVariousArtists": true,
|
"albumVariousArtists": true,
|
||||||
|
@ -70,6 +70,6 @@
|
||||||
"useNullSeparator": false,
|
"useNullSeparator": false,
|
||||||
"saveID3v1": true,
|
"saveID3v1": true,
|
||||||
"multiArtistSeparator": "default",
|
"multiArtistSeparator": "default",
|
||||||
"singleAlbumArtist": false,
|
"singleAlbumArtist": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,7 +612,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
if 'dzcdn.net' in trackAPI["_EXTRA_PLAYLIST"]['picture_small']:
|
if 'dzcdn.net' in trackAPI["_EXTRA_PLAYLIST"]['picture_small']:
|
||||||
track['playlist']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_small'][:-24] + "/{}x{}-{}".format(
|
track['playlist']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_small'][:-24] + "/{}x{}-{}".format(
|
||||||
settings['embeddedArtworkSize'], settings['embeddedArtworkSize'],
|
settings['embeddedArtworkSize'], settings['embeddedArtworkSize'],
|
||||||
'none-100-0-0.png' if settings['PNGcovers'] else f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
||||||
else:
|
else:
|
||||||
track['playlist']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_xl']
|
track['playlist']['picUrl'] = trackAPI["_EXTRA_PLAYLIST"]['picture_xl']
|
||||||
track['playlist']['title'] = trackAPI["_EXTRA_PLAYLIST"]['title']
|
track['playlist']['title'] = trackAPI["_EXTRA_PLAYLIST"]['title']
|
||||||
|
@ -648,7 +648,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
track['date'] = track['album']['date']
|
track['date'] = track['album']['date']
|
||||||
track['album']['picUrl'] = "https://e-cdns-images.dzcdn.net/images/cover/{}/{}x{}-{}".format(
|
track['album']['picUrl'] = "https://e-cdns-images.dzcdn.net/images/cover/{}/{}x{}-{}".format(
|
||||||
track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'],
|
track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'],
|
||||||
'none-100-0-0.png' if settings['PNGcovers'] else f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
||||||
track['album']['bitrate'] = format
|
track['album']['bitrate'] = format
|
||||||
track['dateString'] = formatDate(track['date'], settings['dateFormat'])
|
track['dateString'] = formatDate(track['date'], settings['dateFormat'])
|
||||||
track['album']['dateString'] = formatDate(track['album']['date'], settings['dateFormat'])
|
track['album']['dateString'] = formatDate(track['album']['date'], settings['dateFormat'])
|
||||||
|
@ -700,10 +700,10 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
# Download and cache coverart
|
# Download and cache coverart
|
||||||
if settings['tags']['savePlaylistAsCompilation'] and "_EXTRA_PLAYLIST" in trackAPI:
|
if settings['tags']['savePlaylistAsCompilation'] and "_EXTRA_PLAYLIST" in trackAPI:
|
||||||
track['album']['picPath'] = os.path.join(TEMPDIR,
|
track['album']['picPath'] = os.path.join(TEMPDIR,
|
||||||
f"pl{trackAPI['_EXTRA_PLAYLIST']['id']}_{settings['embeddedArtworkSize']}.{'png' if settings['PNGcovers'] else 'jpg'}")
|
f"pl{trackAPI['_EXTRA_PLAYLIST']['id']}_{settings['embeddedArtworkSize']}.jpg")
|
||||||
else:
|
else:
|
||||||
track['album']['picPath'] = os.path.join(TEMPDIR,
|
track['album']['picPath'] = os.path.join(TEMPDIR,
|
||||||
f"alb{track['album']['id']}_{settings['embeddedArtworkSize']}.{'png' if settings['PNGcovers'] else 'jpg'}")
|
f"alb{track['album']['id']}_{settings['embeddedArtworkSize']}.jpg")
|
||||||
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Getting the album cover")
|
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Getting the album cover")
|
||||||
track['album']['picPath'] = downloadImage(track['album']['picUrl'], track['album']['picPath'])
|
track['album']['picPath'] = downloadImage(track['album']['picUrl'], track['album']['picPath'])
|
||||||
|
|
||||||
|
@ -722,42 +722,58 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
|
||||||
|
|
||||||
# Save local album art
|
# Save local album art
|
||||||
if coverPath:
|
if coverPath:
|
||||||
result['albumURL'] = track['album']['picUrl'].replace(
|
result['albumURLs'] = []
|
||||||
f"{settings['embeddedArtworkSize']}x{settings['embeddedArtworkSize']}",
|
for format in settings['localArtworkFormat'].split(","):
|
||||||
f"{settings['localArtworkSize']}x{settings['localArtworkSize']}")
|
if format in ["png","jpg"]:
|
||||||
|
url = track['album']['picUrl'].replace(
|
||||||
|
f"{settings['embeddedArtworkSize']}x{settings['embeddedArtworkSize']}",
|
||||||
|
f"{settings['localArtworkSize']}x{settings['localArtworkSize']}")
|
||||||
|
if format == "png":
|
||||||
|
url = url[:url.find("000000-")]+"none-100-0-0.png"
|
||||||
|
result['albumURLs'].append({'url': url, 'ext': format})
|
||||||
result['albumPath'] = os.path.join(coverPath,
|
result['albumPath'] = os.path.join(coverPath,
|
||||||
f"{settingsRegexAlbum(settings['coverImageTemplate'], track['album'], settings, trackAPI['_EXTRA_PLAYLIST'] if'_EXTRA_PLAYLIST' in trackAPI else None)}.{'png' if settings['PNGcovers'] else 'jpg'}")
|
f"{settingsRegexAlbum(settings['coverImageTemplate'], track['album'], settings, trackAPI['_EXTRA_PLAYLIST'] if'_EXTRA_PLAYLIST' in trackAPI else None)}")
|
||||||
|
|
||||||
# Save artist art
|
# Save artist art
|
||||||
if artistPath:
|
if artistPath:
|
||||||
if track['album']['mainArtist']['pic'] != "":
|
result['artistURLs'] = []
|
||||||
result['artistURL'] = "https://e-cdns-images.dzcdn.net/images/artist/{}/{}x{}-{}".format(
|
for format in settings['localArtworkFormat'].split(","):
|
||||||
track['album']['mainArtist']['pic'], settings['localArtworkSize'], settings['localArtworkSize'],
|
if format in ["png","jpg"]:
|
||||||
'none-100-0-0.png' if settings['PNGcovers'] else f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
url = ""
|
||||||
result['artistPath'] = os.path.join(artistPath,
|
if track['album']['mainArtist']['pic'] != "":
|
||||||
f"{settingsRegexArtist(settings['artistImageTemplate'], track['album']['mainArtist'], settings)}.{'png' if settings['PNGcovers'] else 'jpg'}")
|
url = "https://e-cdns-images.dzcdn.net/images/artist/{}/{}x{}-{}".format(
|
||||||
else:
|
track['album']['mainArtist']['pic'], settings['localArtworkSize'], settings['localArtworkSize'],
|
||||||
result['artistURL'] = "https://e-cdns-images.dzcdn.net/images/artist//{}x{}-{}".format(
|
'none-100-0-0.png' if format == "png" else f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
||||||
settings['localArtworkSize'], settings['localArtworkSize'], f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
elif format == "jpg":
|
||||||
result['artistPath'] = os.path.join(artistPath,
|
url = "https://e-cdns-images.dzcdn.net/images/artist//{}x{}-{}".format(
|
||||||
f"{settingsRegexArtist(settings['artistImageTemplate'], track['album']['mainArtist'], settings)}.jpg")
|
settings['localArtworkSize'], settings['localArtworkSize'], f'000000-{settings["jpegImageQuality"]}-0-0.jpg')
|
||||||
|
if url:
|
||||||
|
result['artistURLs'].append({'url': url, 'ext': format})
|
||||||
|
result['artistPath'] = os.path.join(artistPath,
|
||||||
|
f"{settingsRegexArtist(settings['artistImageTemplate'], track['album']['mainArtist'], settings)}")
|
||||||
|
|
||||||
# Data for m3u file
|
# Data for m3u file
|
||||||
if extrasPath:
|
if extrasPath:
|
||||||
result['extrasPath'] = extrasPath
|
result['extrasPath'] = extrasPath
|
||||||
result['playlistPosition'] = writepath[len(extrasPath):]
|
result['playlistPosition'] = writepath[len(extrasPath):]
|
||||||
if "playlist" in track:
|
if "playlist" in track:
|
||||||
|
result['playlistURLs'] = []
|
||||||
if 'dzcdn.net' in track['playlist']['picUrl']:
|
if 'dzcdn.net' in track['playlist']['picUrl']:
|
||||||
result['playlistURL'] = track['playlist']['picUrl'].replace(
|
for format in settings['localArtworkFormat'].split(","):
|
||||||
f"{settings['embeddedArtworkSize']}x{settings['embeddedArtworkSize']}",
|
if format in ["png","jpg"]:
|
||||||
f"{settings['localArtworkSize']}x{settings['localArtworkSize']}")
|
url = track['playlist']['picUrl'].replace(
|
||||||
|
f"{settings['embeddedArtworkSize']}x{settings['embeddedArtworkSize']}",
|
||||||
|
f"{settings['localArtworkSize']}x{settings['localArtworkSize']}")
|
||||||
|
if format == "png":
|
||||||
|
url = url[:url.find("000000-")]+"none-100-0-0.png"
|
||||||
|
result['playlistURLs'].append({'url': url, 'ext': format})
|
||||||
else:
|
else:
|
||||||
result['playlistURL'] = track['playlist']['picUrl']
|
result['playlistURLs'].append({'url': track['playlist']['picUrl'], 'ext': 'jpg'})
|
||||||
track['playlist']['id'] = "pl_" + str(trackAPI['_EXTRA_PLAYLIST']['id'])
|
track['playlist']['id'] = "pl_" + str(trackAPI['_EXTRA_PLAYLIST']['id'])
|
||||||
track['playlist']['genre'] = ["Compilation", ]
|
track['playlist']['genre'] = ["Compilation", ]
|
||||||
track['playlist']['bitrate'] = format
|
track['playlist']['bitrate'] = format
|
||||||
track['playlist']['dateString'] = formatDate(track['playlist']['date'], settings['dateFormat'])
|
track['playlist']['dateString'] = formatDate(track['playlist']['date'], settings['dateFormat'])
|
||||||
result['playlistCover'] = f"{settingsRegexAlbum(settings['coverImageTemplate'], track['playlist'], settings, trackAPI['_EXTRA_PLAYLIST'])}.{'png' if settings['PNGcovers'] else 'jpg'}"
|
result['playlistCover'] = f"{settingsRegexAlbum(settings['coverImageTemplate'], track['playlist'], settings, trackAPI['_EXTRA_PLAYLIST'])}"
|
||||||
|
|
||||||
track['downloadUrl'] = dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'],
|
track['downloadUrl'] = dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'],
|
||||||
track['selectedFormat'])
|
track['selectedFormat'])
|
||||||
|
@ -941,9 +957,11 @@ def after_download(tracks, settings, queueItem):
|
||||||
playlistCover = result['playlistCover']
|
playlistCover = result['playlistCover']
|
||||||
playlistURL = result['playlistURL']
|
playlistURL = result['playlistURL']
|
||||||
if settings['saveArtwork'] and 'albumPath' in result:
|
if settings['saveArtwork'] and 'albumPath' in result:
|
||||||
downloadImage(result['albumURL'], result['albumPath'], settings['overwriteFile'])
|
for image in result['albumURLs']:
|
||||||
|
downloadImage(image['url'], f"{result['albumPath']}.{image['ext']}", settings['overwriteFile'])
|
||||||
if settings['saveArtworkArtist'] and 'artistPath' in result:
|
if settings['saveArtworkArtist'] and 'artistPath' in result:
|
||||||
downloadImage(result['artistURL'], result['artistPath'], settings['overwriteFile'])
|
for image in result['artistURLs']:
|
||||||
|
downloadImage(image['url'], f"{result['artistPath']}.{image['ext']}", settings['overwriteFile'])
|
||||||
if 'playlistPosition' in result:
|
if 'playlistPosition' in result:
|
||||||
playlist[index] = result['playlistPosition']
|
playlist[index] = result['playlistPosition']
|
||||||
else:
|
else:
|
||||||
|
@ -954,7 +972,8 @@ def after_download(tracks, settings, queueItem):
|
||||||
with open(os.path.join(extrasPath, 'errors.txt'), 'wb') as f:
|
with open(os.path.join(extrasPath, 'errors.txt'), 'wb') as f:
|
||||||
f.write(errors.encode('utf-8'))
|
f.write(errors.encode('utf-8'))
|
||||||
if settings['saveArtwork'] and playlistCover and not settings['tags']['savePlaylistAsCompilation']:
|
if settings['saveArtwork'] and playlistCover and not settings['tags']['savePlaylistAsCompilation']:
|
||||||
downloadImage(playlistURL, os.path.join(extrasPath, playlistCover), settings['overwriteFile'])
|
for image in result['playlistURLs']:
|
||||||
|
downloadImage(image['url'], os.path.join(extrasPath, playlistCover)+f".{image['ext']}", settings['overwriteFile'])
|
||||||
if settings['logSearched'] and searched != "":
|
if settings['logSearched'] and searched != "":
|
||||||
with open(os.path.join(extrasPath, 'searched.txt'), 'wb') as f:
|
with open(os.path.join(extrasPath, 'searched.txt'), 'wb') as f:
|
||||||
f.write(searched.encode('utf-8'))
|
f.write(searched.encode('utf-8'))
|
||||||
|
@ -974,9 +993,11 @@ def after_download_single(track, settings, queueItem):
|
||||||
if 'extrasPath' not in track:
|
if 'extrasPath' not in track:
|
||||||
track['extrasPath'] = settings['downloadLocation']
|
track['extrasPath'] = settings['downloadLocation']
|
||||||
if settings['saveArtwork'] and 'albumPath' in track:
|
if settings['saveArtwork'] and 'albumPath' in track:
|
||||||
downloadImage(track['albumURL'], track['albumPath'], settings['overwriteFile'])
|
for image in result['albumURLs']:
|
||||||
|
downloadImage(image['url'], f"{result['albumPath']}.{image['ext']}", settings['overwriteFile'])
|
||||||
if settings['saveArtworkArtist'] and 'artistPath' in track:
|
if settings['saveArtworkArtist'] and 'artistPath' in track:
|
||||||
downloadImage(track['artistURL'], track['artistPath'], settings['overwriteFile'])
|
for image in result['artistURLs']:
|
||||||
|
downloadImage(image['url'], f"{result['artistPath']}.{image['ext']}", settings['overwriteFile'])
|
||||||
if settings['logSearched'] and 'searched' in track:
|
if settings['logSearched'] and 'searched' in track:
|
||||||
with open(os.path.join(track['extrasPath'], 'searched.txt'), 'wb+') as f:
|
with open(os.path.join(track['extrasPath'], 'searched.txt'), 'wb+') as f:
|
||||||
orig = f.read().decode('utf-8')
|
orig = f.read().decode('utf-8')
|
||||||
|
|
Loading…
Reference in New Issue