From f9f491ea65691f0553cd324e6ad311dd055d6ce7 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 21 May 2020 03:30:17 +0200 Subject: [PATCH] readd cloudflare check --- pirate/torrent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pirate/torrent.py b/pirate/torrent.py index a6c2cbf..3c0b2f2 100644 --- a/pirate/torrent.py +++ b/pirate/torrent.py @@ -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',