Browse Source

Don't use download handler if it isn't needed

pull/69/head
Ruud 14 years ago
parent
commit
e3ff4a46d5
  1. 25
      couchpotato/core/downloaders/sabnzbd/main.py
  2. 10
      couchpotato/core/providers/nzb/x264/main.py

25
couchpotato/core/downloaders/sabnzbd/main.py

@ -7,6 +7,7 @@ import base64
import os
import re
import traceback
from couchpotato.core.helpers.encoding import toUnicode
log = CPLog(__name__)
@ -34,22 +35,25 @@ class Sabnzbd(Downloader):
else:
pp = False
params = {
'apikey': self.conf('api_key'),
'cat': self.conf('category'),
'mode': 'addfile',
'mode': 'addurl',
'nzbname': '%s%s' % (data.get('name'), self.cpTag(movie)),
}
nzb_file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
if data.get('download'):
nzb_file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
if len(nzb_file) < 50:
log.error('No nzb available!')
return False
if len(nzb_file) < 50:
log.error('No nzb available!')
return False
# If it's a .rar, it adds the .rar extension, otherwise it stays .nzb
nzb_filename = self.createFileName(data, nzb_file, movie)
# If it's a .rar, it adds the .rar extension, otherwise it stays .nzb
nzb_filename = self.createFileName(data, nzb_file, movie)
params['mode'] = 'addfile'
else:
params['name'] = data.get('url')
if pp:
params['script'] = pp_script_fn
@ -57,7 +61,10 @@ class Sabnzbd(Downloader):
url = cleanHost(self.conf('host')) + "api?" + urlencode(params)
try:
data = self.urlopen(url, params = {"nzbfile": (nzb_filename, nzb_file)}, multipart = True, show_error = False)
if params.get('mode') is 'addfile':
data = self.urlopen(url, params = {"nzbfile": (nzb_filename, nzb_file)}, multipart = True, show_error = False)
else:
data = self.urlopen(url, show_error = False)
except:
log.error(traceback.format_exc())
return False

10
couchpotato/core/providers/nzb/x264/main.py

@ -46,7 +46,6 @@ class X264(NZBProvider):
'age': tryInt(age),
'size': None,
'url': self.urls['download'] % (nzb.group('id')),
'download': self.download,
'detail_url': '',
'description': '',
'check_nzb': False,
@ -62,15 +61,6 @@ class X264(NZBProvider):
return results
def download(self, url = '', nzb_id = ''):
try:
log.info('Downloading nzb from #alt.binaries.hdtv.x264, request id: %s ' % nzb_id)
return self.urlopen(self.urls['download'] % nzb_id)
except Exception, e:
log.error('Failed downloading from #alt.binaries.hdtv.x264: %s' % e)
return False
def belongsTo(self, url, host = None):
match = re.match('http://85\.214\.105\.230/get_nzb\.php\?id=[0-9]*&section=hd', url)
if match:

Loading…
Cancel
Save