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 global spotify
spotify = spotipy.Spotify(auth=token) spotify = spotipy.Spotify(auth=token)
grab_single(raw_song, number=number) grab_single(raw_song, number=number)
except KeyboardInterrupt: except (urllib2.URLError, requests.exceptions.ConnectionError, IOError):
misc.grace_quit()
except (urllib2.URLError, IOError):
lines.append(raw_song) lines.append(raw_song)
misc.trim_song(file) misc.trim_song(file)
with open(file, 'a') as myfile: with open(file, 'a') as myfile:
myfile.write(raw_song) myfile.write(raw_song)
print('Failed to download song. Will retry after other songs.') print('Failed to download song. Will retry after other songs.')
continue continue
except KeyboardInterrupt:
misc.grace_quit()
finally: finally:
print('') print('')
misc.trim_song(file) misc.trim_song(file)