From 03d577eb72fb48633578b2d23372ed328c667d7a Mon Sep 17 00:00:00 2001 From: evanjd Date: Sun, 26 Jan 2014 22:03:17 +1100 Subject: [PATCH 1/2] Fix for issues with what.cd authentication --- lib/pygazelle/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pygazelle/api.py b/lib/pygazelle/api.py index 4e93b47d..a778b93a 100644 --- a/lib/pygazelle/api.py +++ b/lib/pygazelle/api.py @@ -98,7 +98,7 @@ class GazelleAPI(object): loginpage = 'https://what.cd/login.php' data = {'username': self.username, 'password': self.password} - r = self.session.post(loginpage, data=data, timeout=self.default_timeout) + r = self.session.post(loginpage, data=data, timeout=self.default_timeout, headers=self.default_headers) self.past_request_timestamps.append(time.time()) if r.status_code != 200: raise LoginException("Login returned status code %s" % r.status_code) From afe9a0259e13106b5111ec9cb537ff691a7835c2 Mon Sep 17 00:00:00 2001 From: Evan Bruhn Date: Mon, 27 Jan 2014 14:05:09 +1100 Subject: [PATCH 2/2] Fixes what.cd snatches getting stuck at pre-processing with blackhole downloader Cloudflare requires a user-agent header otherwise will return 403 forbidden. --- headphones/searcher.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/headphones/searcher.py b/headphones/searcher.py index 108feae4..0b64e002 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -1553,6 +1553,9 @@ def preprocesstorrent(resultlist, pre_sorted_list=False): if result[3] == 'Kick Ass Torrent': request.add_header('Referer', 'http://kat.ph/') + if result[3] == 'What.cd': + request.add_header('User-Agent', 'Headphones') + response = urllib2.urlopen(request) if response.info().get('Content-Encoding') == 'gzip': buf = StringIO(response.read())