From 2f654602f7e78426a11521ce67d92b03586c6f5b Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 9 Oct 2011 19:13:15 +0200 Subject: [PATCH] Newzbin fix --- couchpotato/core/providers/nzb/newzbin/main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/couchpotato/core/providers/nzb/newzbin/main.py b/couchpotato/core/providers/nzb/newzbin/main.py index 2f31d325..498a8e9a 100644 --- a/couchpotato/core/providers/nzb/newzbin/main.py +++ b/couchpotato/core/providers/nzb/newzbin/main.py @@ -4,6 +4,7 @@ from couchpotato.core.logger import CPLog from couchpotato.core.providers.nzb.base import NZBProvider from dateutil.parser import parse from urllib import urlencode +import base64 import time import xml.etree.ElementTree as XMLTree @@ -55,20 +56,20 @@ class Newzbin(NZBProvider, RSS): 'ps_rb_source': str(format_id), }) - url = "%s?%s" % (self.url['search'], arguments) + url = "%s?%s" % (self.urls['search'], arguments) cache_key = str('newzbin.%s.%s.%s' % (movie['library']['identifier'], str(format_id), str(cat_id))) single_cat = True data = self.getCache(cache_key) if not data: - data = self.urlopen(url, params = {'username': self.conf('username'), 'password': self.conf('password')}) + + headers = { + 'Authorization': "Basic %s" % base64.encodestring('%s:%s' % (self.conf('username'), self.conf('password')))[:-1] + } + + data = self.urlopen(url, headers = headers) self.setCache(cache_key, data) - if not data: - log.error('Failed to get data from %s.' % url) - return results - - if data: try: try: @@ -125,7 +126,7 @@ class Newzbin(NZBProvider, RSS): try: log.info('Download nzb from newzbin, report id: %s ' % nzb_id) - return self.urlopen(self.url['download'], params = { + return self.urlopen(self.urls['download'], params = { 'username' : self.conf('username'), 'password' : self.conf('password'), 'reportid' : nzb_id