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