Outputs error details when track download fails from list file (#406)

This commit is contained in:
Manveer Basra
2018-10-24 12:36:39 -04:00
committed by Ritiek Malhotra
parent 94f0b3e95d
commit 680525ea3d

View File

@@ -101,13 +101,14 @@ def download_list(tracks_file, skip_file=None, write_successful_file=None):
spotify_tools.spotify = spotipy.Spotify(auth=new_token)
download_single(raw_song, number=number)
# detect network problems
except (urllib.request.URLError, TypeError, IOError):
except (urllib.request.URLError, TypeError, IOError) as e:
tracks.append(raw_song)
# remove the downloaded song from file
internals.trim_song(tracks_file)
# and append it at the end of file
with open(tracks_file, "a") as f:
f.write("\n" + raw_song)
log.exception(e)
log.warning("Failed to download song. Will retry after other songs\n")
# wait 0.5 sec to avoid infinite looping
time.sleep(0.5)