mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-09 09:59:51 +01:00
Fixed error handling
On my computer it's failing on the first request to https://thepiratebay.org/ . I think the properties this code is handling need an HTTPError according to the doc https://docs.python.org/3/library/urllib.error.html\#urllib.error.URLError
This commit is contained in:
parent
1e9b3142a2
commit
3ad8620fbd
@ -146,7 +146,7 @@ def find_api(mirror, timeout):
|
||||
f = request.urlopen(req, timeout=timeout)
|
||||
if f.info().get_content_type() == 'application/json':
|
||||
return mirror + path
|
||||
except urllib.error.URLError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
res = e.fp.read().decode()
|
||||
if e.code == 503 and 'cf-browser-verification' in res:
|
||||
raise IOError('Cloudflare protected')
|
||||
|
Loading…
Reference in New Issue
Block a user