Don't use download handler if it isn't needed
This commit is contained in:
1 parent
94cfbe354a
commit
e3ff4a46d5
2 files changed
+16
-19
No files matched your search
@@ -7,6 +7,7 @@ import base64
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -34,22 +35,25 @@ class Sabnzbd(Downloader):
|
|||||||
else:
|
else:
|
||||||
pp = False
|
pp = False
|
||||||
|
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'apikey': self.conf('api_key'),
|
'apikey': self.conf('api_key'),
|
||||||
'cat': self.conf('category'),
|
'cat': self.conf('category'),
|
||||||
'mode': 'addfile',
|
'mode': 'addurl',
|
||||||
'nzbname': '%s%s' % (data.get('name'), self.cpTag(movie)),
|
'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:
|
if len(nzb_file) < 50:
|
||||||
log.error('No nzb available!')
|
log.error('No nzb available!')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# If it's a .rar, it adds the .rar extension, otherwise it stays .nzb
|
# If it's a .rar, it adds the .rar extension, otherwise it stays .nzb
|
||||||
nzb_filename = self.createFileName(data, nzb_file, movie)
|
nzb_filename = self.createFileName(data, nzb_file, movie)
|
||||||
|
params['mode'] = 'addfile'
|
||||||
|
else:
|
||||||
|
params['name'] = data.get('url')
|
||||||
|
|
||||||
if pp:
|
if pp:
|
||||||
params['script'] = pp_script_fn
|
params['script'] = pp_script_fn
|
||||||
@@ -57,7 +61,10 @@ class Sabnzbd(Downloader):
|
|||||||
url = cleanHost(self.conf('host')) + "api?" + urlencode(params)
|
url = cleanHost(self.conf('host')) + "api?" + urlencode(params)
|
||||||
|
|
||||||
try:
|
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:
|
except:
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ class X264(NZBProvider):
|
|||||||
'age': tryInt(age),
|
'age': tryInt(age),
|
||||||
'size': None,
|
'size': None,
|
||||||
'url': self.urls['download'] % (nzb.group('id')),
|
'url': self.urls['download'] % (nzb.group('id')),
|
||||||
'download': self.download,
|
|
||||||
'detail_url': '',
|
'detail_url': '',
|
||||||
'description': '',
|
'description': '',
|
||||||
'check_nzb': False,
|
'check_nzb': False,
|
||||||
@@ -62,15 +61,6 @@ class X264(NZBProvider):
|
|||||||
|
|
||||||
return results
|
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):
|
def belongsTo(self, url, host = None):
|
||||||
match = re.match('http://85\.214\.105\.230/get_nzb\.php\?id=[0-9]*§ion=hd', url)
|
match = re.match('http://85\.214\.105\.230/get_nzb\.php\?id=[0-9]*§ion=hd', url)
|
||||||
if match:
|
if match:
|
||||||
|
|||||||
Reference in new issue
Block a user