1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-04-13 00:28:38 +02:00

readd cloudflare check

This commit is contained in:
Michele Guerini Rocco 2020-05-21 03:30:17 +02:00
parent 2b659305ec
commit f9f491ea65
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -115,8 +115,10 @@ 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:
pass
except urllib.error.URLError as e:
res = e.fp.read().decode()
if e.code == 503 and 'cf-browser-verification' in res:
raise IOError('Cloudflare protected')
# extract api path from main.js
req = request.Request(mirror + '/static/main.js',