From 776a988fb4bf965331695808df3243e9a92527d6 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 4 Jun 2011 21:28:33 +0200 Subject: [PATCH] Add cp(ttxxxxxx) to downloaders --- couchpotato/core/downloaders/blackhole/main.py | 5 +++-- couchpotato/core/downloaders/sabnzbd/__init__.py | 5 +++++ couchpotato/core/downloaders/sabnzbd/main.py | 15 +++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/couchpotato/core/downloaders/blackhole/main.py b/couchpotato/core/downloaders/blackhole/main.py index fbb6ef35..47650a13 100644 --- a/couchpotato/core/downloaders/blackhole/main.py +++ b/couchpotato/core/downloaders/blackhole/main.py @@ -13,7 +13,7 @@ class Blackhole(Downloader): type = ['nzb', 'torrent'] - def download(self, data = {}): + def download(self, data = {}, movie = {}): if self.isDisabled() or not self.isCorrectType(data.get('type')): return @@ -23,7 +23,8 @@ class Blackhole(Downloader): if not directory or not os.path.isdir(directory): log.error('No directory set for blackhole %s download.' % data.get('type')) else: - fullPath = os.path.join(directory, toSafeString(data.get('name')) + '.' + data.get('type')) + cp_tag = '.cp(' + movie['library'].get('identifier') + ')' if movie['library'].get('identifier') else '' + fullPath = os.path.join(directory, '%s%s.%s' % (toSafeString(data.get('name')), cp_tag , data.get('type'))) try: if not os.path.isfile(fullPath): diff --git a/couchpotato/core/downloaders/sabnzbd/__init__.py b/couchpotato/core/downloaders/sabnzbd/__init__.py index 4d49c4d7..028f139f 100644 --- a/couchpotato/core/downloaders/sabnzbd/__init__.py +++ b/couchpotato/core/downloaders/sabnzbd/__init__.py @@ -26,6 +26,11 @@ config = [{ 'label': 'Api Key', 'description': 'Used for all calls to Sabnzbd.', }, + { + 'name': 'category', + 'label': 'Category', + 'description': 'The category CP places the nzb in. Like movies or couchpotato', + }, { 'advanced': True, 'name': 'pp_directory', diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py index 344aa5f1..eb648f57 100644 --- a/couchpotato/core/downloaders/sabnzbd/main.py +++ b/couchpotato/core/downloaders/sabnzbd/main.py @@ -14,7 +14,7 @@ class Sabnzbd(Downloader): type = ['nzb'] - def download(self, data = {}): + def download(self, data = {}, movie = {}): if self.isDisabled() or not self.isCorrectType(data.get('type')): return @@ -34,11 +34,14 @@ class Sabnzbd(Downloader): else: pp = False + + cp_tag = '.cp(' + movie['library'].get('identifier') + ')' if movie['library'].get('identifier') else '' params = { - 'apikey': self.conf('apikey'), + 'apikey': self.conf('api_key'), 'cat': self.conf('category'), 'mode': 'addurl', - 'name': data.get('url') + 'name': data.get('url'), + 'nzbname': '%s%s' % (data.get('name'), cp_tag), } # sabNzbd complains about "invalid archive file" for newzbin urls @@ -53,9 +56,9 @@ class Sabnzbd(Downloader): log.info("URL: " + url) try: - r = urllib2.urlopen(url, timeout = 30) - except: - log.error("Unable to connect to SAB.") + r = urllib2.urlopen(url) + except Exception, e: + log.error("Unable to connect to SAB: %s" % e) return False result = r.read().strip()