1
0
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:
Michele Guerini Rocco 2020-06-20 23:28:13 +02:00 committed by GitHub
commit a36626374e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')