mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
Merge pull request #137 from morhook/fix_error_handling
Fixed error handling
This commit is contained in:
commit
a36626374e
@ -146,7 +146,7 @@ def find_api(mirror, timeout):
|
|||||||
f = request.urlopen(req, timeout=timeout)
|
f = request.urlopen(req, timeout=timeout)
|
||||||
if f.info().get_content_type() == 'application/json':
|
if f.info().get_content_type() == 'application/json':
|
||||||
return mirror + path
|
return mirror + path
|
||||||
except urllib.error.URLError as e:
|
except urllib.error.HTTPError as e:
|
||||||
res = e.fp.read().decode()
|
res = e.fp.read().decode()
|
||||||
if e.code == 503 and 'cf-browser-verification' in res:
|
if e.code == 503 and 'cf-browser-verification' in res:
|
||||||
raise IOError('Cloudflare protected')
|
raise IOError('Cloudflare protected')
|
||||||
|
Loading…
Reference in New Issue
Block a user