Downloading of single releases and more

This commit is contained in:
Ruud committed 2011-09-11 00:58:26 +02:00
1 parent 4617750277
commit cb5fc694ab
31 files changed
+457 -112

No files matched your search

@@ -27,18 +27,16 @@ class Blackhole(Downloader):
try:
if not os.path.isfile(fullPath):
log.info('Downloading %s to %s.' % (data.get('type'), fullPath))
if isfunction(data.get('download')):
file = data.get('download')()
else:
file = self.urlopen(data.get('url'))
if not file or file == '':
try:
file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
with open(fullPath, 'wb') as f:
f.write(file)
except:
log.debug('Failed download file: %s' % data.get('name'))
return False
with open(fullPath, 'wb') as f:
f.write(file)
return True
else:
log.info('File %s already exists.' % fullPath)
+8 -11
View File
@@ -6,6 +6,7 @@ from urllib import urlencode
import base64
import os
import re
import traceback
log = CPLog(__name__)
@@ -37,15 +38,11 @@ class Sabnzbd(Downloader):
params = {
'apikey': self.conf('api_key'),
'cat': self.conf('category'),
'mode': 'addurl',
'name': data.get('url'),
'mode': 'addfile',
'nzbname': '%s%s' % (data.get('name'), self.cpTag(movie)),
}
# sabNzbd complains about "invalid archive file" for newzbin urls
# added using addurl, works fine with addid
if data.get('addbyid'):
params['mode'] = 'addid'
nzb_file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
if pp:
params['script'] = pp_script_fn
@@ -53,9 +50,9 @@ class Sabnzbd(Downloader):
url = cleanHost(self.conf('host')) + "api?" + urlencode(params)
try:
data = self.urlopen(url)
except Exception, e:
log.error("Unable to connect to SAB: %s" % e)
data = self.urlopen(url, params = {"nzbfile": (params['nzbname'] + ".nzb", nzb_file)}, multipart = True)
except Exception:
log.error("Unable to connect to SAB: %s" % traceback.format_exc())
return False
result = data.strip()
@@ -63,7 +60,7 @@ class Sabnzbd(Downloader):
log.error("SABnzbd didn't return anything.")
return False
log.debug("Result text from SAB: " + result)
log.debug("Result text from SAB: " + result[:40])
if result == "ok":
log.info("NZB sent to SAB successfully.")
return True
@@ -71,7 +68,7 @@ class Sabnzbd(Downloader):
log.error("Incorrect username/password.")
return False
else:
log.error("Unknown error: " + result)
log.error("Unknown error: " + result[:40])
return False
def buildPp(self, imdb_id):