Fix albumart exception in .M4A downloads

This commit is contained in:
ritiek
2017-09-27 10:26:03 +05:30
parent f9e85d3796
commit 9068f6008e

View File

@@ -74,7 +74,7 @@ def embed_mp3(music_file, meta_tags):
desc=u'Cover', data=albumart.read()) desc=u'Cover', data=albumart.read())
albumart.close() albumart.close()
except IndexError: except IndexError:
albumart = None pass
audiofile.save(v2_version=3) audiofile.save(v2_version=3)
return True return True
@@ -114,9 +114,12 @@ def embed_m4a(music_file, meta_tags):
audiofile[tags['genre']] = meta_tags['genre'] audiofile[tags['genre']] = meta_tags['genre']
if meta_tags['copyright']: if meta_tags['copyright']:
audiofile[tags['copyright']] = meta_tags['copyright'] audiofile[tags['copyright']] = meta_tags['copyright']
try:
albumart = urllib.request.urlopen(meta_tags['album']['images'][0]['url']) albumart = urllib.request.urlopen(meta_tags['album']['images'][0]['url'])
audiofile[tags['albumart']] = [MP4Cover( audiofile[tags['albumart']] = [MP4Cover(
albumart.read(), imageformat=MP4Cover.FORMAT_JPEG)] albumart.read(), imageformat=MP4Cover.FORMAT_JPEG)]
albumart.close() albumart.close()
except IndexError:
pass
audiofile.save() audiofile.save()
return True return True