Add cp(ttxxxxxx) to downloaders

This commit is contained in:
Ruud
2011-06-04 21:28:33 +02:00
parent ec7164c308
commit 776a988fb4
3 changed files with 17 additions and 8 deletions
@@ -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):
@@ -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 <strong>movies</strong> or <strong>couchpotato</strong>',
},
{
'advanced': True,
'name': 'pp_directory',
+9 -6
View File
@@ -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()