Capture requests.exception.ConnectionError

This commit is contained in:
Ritiek Malhotra
2017-06-16 16:21:31 +05:30
committed by GitHub
parent 5d3c27b622
commit 70f18067db

View File

@@ -261,15 +261,15 @@ def grab_list(file):
global spotify
spotify = spotipy.Spotify(auth=token)
grab_single(raw_song, number=number)
except KeyboardInterrupt:
misc.grace_quit()
except (urllib2.URLError, IOError):
except (urllib2.URLError, requests.exceptions.ConnectionError, IOError):
lines.append(raw_song)
misc.trim_song(file)
with open(file, 'a') as myfile:
myfile.write(raw_song)
print('Failed to download song. Will retry after other songs.')
continue
except KeyboardInterrupt:
misc.grace_quit()
finally:
print('')
misc.trim_song(file)