mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
albumart out of range exception
This commit is contained in:
@@ -68,10 +68,13 @@ def embed_mp3(music_file, meta_tags):
|
|||||||
audiofile['isrc'] = meta_tags['external_ids']['isrc']
|
audiofile['isrc'] = meta_tags['external_ids']['isrc']
|
||||||
audiofile.save(v2_version=3)
|
audiofile.save(v2_version=3)
|
||||||
audiofile = ID3(music_file)
|
audiofile = ID3(music_file)
|
||||||
|
try:
|
||||||
albumart = urllib.request.urlopen(meta_tags['album']['images'][0]['url'])
|
albumart = urllib.request.urlopen(meta_tags['album']['images'][0]['url'])
|
||||||
audiofile["APIC"] = APIC(encoding=3, mime='image/jpeg', type=3,
|
audiofile["APIC"] = APIC(encoding=3, mime='image/jpeg', type=3,
|
||||||
desc=u'Cover', data=albumart.read())
|
desc=u'Cover', data=albumart.read())
|
||||||
albumart.close()
|
albumart.close()
|
||||||
|
except IndexError:
|
||||||
|
albumart = None
|
||||||
audiofile.save(v2_version=3)
|
audiofile.save(v2_version=3)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -362,10 +362,11 @@ def grab_single(raw_song, number=None):
|
|||||||
|
|
||||||
# generate file name of the song to download
|
# generate file name of the song to download
|
||||||
meta_tags = generate_metadata(raw_song)
|
meta_tags = generate_metadata(raw_song)
|
||||||
if meta_tags is None:
|
|
||||||
songname = content.title
|
|
||||||
else:
|
|
||||||
songname = generate_songname(meta_tags)
|
songname = generate_songname(meta_tags)
|
||||||
|
|
||||||
|
if meta_tags is None or songname == ' - ':
|
||||||
|
songname = content.title
|
||||||
|
|
||||||
file_name = misc.sanitize_title(songname)
|
file_name = misc.sanitize_title(songname)
|
||||||
|
|
||||||
if not check_exists(file_name, raw_song, islist=islist):
|
if not check_exists(file_name, raw_song, islist=islist):
|
||||||
|
|||||||
Reference in New Issue
Block a user