Implemented png covers option

This commit is contained in:
RemixDev 2020-02-27 18:46:32 +01:00
parent 0a7380110a
commit 4a3d52637f
3 changed files with 5 additions and 4 deletions

View File

@ -29,6 +29,7 @@
"coverImageTemplate": "cover", "coverImageTemplate": "cover",
"saveArtworkArtist": false, "saveArtworkArtist": false,
"artistImageTemplate": "folder", "artistImageTemplate": "folder",
"PNGcovers": false,
"multitagSeparator": "default", "multitagSeparator": "default",
"dateFormat": "YMD", "dateFormat": "YMD",
"savePlaylistAsCompilation": false, "savePlaylistAsCompilation": false,

View File

@ -253,14 +253,14 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False, extraTrack=None
track['selectedFormat'] = format track['selectedFormat'] = format
track['selectedFilesize'] = filesize track['selectedFilesize'] = filesize
track['album']['bitrate'] = format track['album']['bitrate'] = format
track['album']['picUrl'] = "http://e-cdn-images.deezer.com/images/cover/{}/{}x{}-000000-80-0-0.jpg".format(track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize']) track['album']['picUrl'] = "http://e-cdn-images.deezer.com/images/cover/{}/{}x{}-000000-80-0-0.{}".format(track['album']['pic'], settings['embeddedArtworkSize'], settings['embeddedArtworkSize'], 'png' if settings['PNGcovers'] else 'jpg')
# Generate filename and filepath from metadata # Generate filename and filepath from metadata
filename = generateFilename(track, trackAPI, settings) + extensions[track['selectedFormat']] filename = generateFilename(track, trackAPI, settings) + extensions[track['selectedFormat']]
(filepath, artistPath, coverPath, extrasPath) = generateFilepath(track, trackAPI, settings) (filepath, artistPath, coverPath, extrasPath) = generateFilepath(track, trackAPI, settings)
# Download and cache coverart # Download and cache coverart
track['album']['picPath'] = os.path.join(TEMPDIR, f"alb{track['album']['id']}_{settings['embeddedArtworkSize']}.jpg") track['album']['picPath'] = os.path.join(TEMPDIR, f"alb{track['album']['id']}_{settings['embeddedArtworkSize']}.{'png' if settings['PNGcovers'] else 'jpg'}")
if not os.path.isfile(track['album']['picPath']): if not os.path.isfile(track['album']['picPath']):
with open(track['album']['picPath'], 'wb') as f: with open(track['album']['picPath'], 'wb') as f:
try: try:

View File

@ -56,7 +56,7 @@ def tagID3(stream, track, save):
tag.add(TCOP(text=track['copyright'])) tag.add(TCOP(text=track['copyright']))
if save['cover'] and track['album']['picPath']: if save['cover'] and track['album']['picPath']:
with open(track['album']['picPath'], 'rb') as f: with open(track['album']['picPath'], 'rb') as f:
tag.add(APIC(3, 'image/jpeg', 3, data=f.read())) tag.add(APIC(3, 'image/jpeg' if track['album']['picPath'].endswith('jpg') else 'image/png', 3, data=f.read()))
tag.save(stream, v1=2, v2_version=3, v23_sep=None) tag.save(stream, v1=2, v2_version=3, v23_sep=None)
@ -114,7 +114,7 @@ def tagFLAC(stream, track, save):
if save['cover'] and track['album']['picPath']: if save['cover'] and track['album']['picPath']:
image = Picture() image = Picture()
image.type = 3 image.type = 3
image.mime = 'image/jpeg' image.mime = 'image/jpeg' if track['album']['picPath'].endswith('jpg') else 'image/png'
with open(track['album']['picPath'], 'rb') as f: with open(track['album']['picPath'], 'rb') as f:
image.data = f.read() image.data = f.read()
tag.add_picture(image) tag.add_picture(image)