From 756a7f69e79c3634240bc6b2e5ce84d9d68ffb53 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 21 Jul 2013 20:37:36 +0530 Subject: [PATCH] Added request header for fetching nzbs from Headphones Index --- headphones/searcher.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/headphones/searcher.py b/headphones/searcher.py index a7c51a9b..c46504bf 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -669,6 +669,18 @@ def getresultNZB(result): getresultNZB(result) except AttributeError: logger.warn("AttributeError in getresultNZB.") + elif result[3] == 'headphones': + request = urllib2.Request(result[2]) + request.add_header('User-Agent', 'headphones/0.0 +https://github.com/rembo10/headphones') + base64string = base64.encodestring('%s:%s' % (headphones.HPUSER, headphones.HPPASS)).replace('\n', '') + request.add_header("Authorization", "Basic %s" % base64string) + + opener = urllib2.build_opener() + + try: + nzb = opener.open(request).read() + except Exception, e: + logger.warn('Error fetching nzb from url: ' + result[2] + ' %s' % e) else: request = urllib2.Request(result[2]) request.add_header('User-Agent', 'headphones/0.0 +https://github.com/rembo10/headphones')