mirror of
https://github.com/caseychu/spotify-backup.git
synced 2024-05-11 10:51:31 +00:00
Merge pull request #6 from bitsofpancake/incomplete-read
Retries all failed requests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import argparse
|
||||
import codecs
|
||||
import http.client
|
||||
import http.server
|
||||
import json
|
||||
import re
|
||||
@@ -34,8 +35,8 @@ class SpotifyAPI:
|
||||
res = urllib.request.urlopen(req)
|
||||
reader = codecs.getreader('utf-8')
|
||||
return json.load(reader(res))
|
||||
except urllib.error.HTTPError as err:
|
||||
log('Couldn\'t load URL: {} ({} {})'.format(url, err.code, err.reason))
|
||||
except Exception as err:
|
||||
log('Couldn\'t load URL: {} ({})'.format(url, err))
|
||||
time.sleep(2)
|
||||
log('Trying again...')
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user