Blackhole support for rarred and empty (faulty) nzbs.
This commit is contained in:
1 parent
3f0d71a8fe
commit
20277ee244
3 files changed
+21
-11
No files matched your search
@@ -2,4 +2,3 @@
|
|||||||
/logs/*.log
|
/logs/*.log
|
||||||
/_source/
|
/_source/
|
||||||
/_data/
|
/_data/
|
||||||
*.pyc
|
|
||||||
@@ -16,6 +16,9 @@ class Downloader(Plugin):
|
|||||||
def download(self, data = {}):
|
def download(self, data = {}):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def createFileExtension(self, data = {}, content):
|
||||||
|
pass
|
||||||
|
|
||||||
def cpTag(self, movie):
|
def cpTag(self, movie):
|
||||||
if Env.setting('enabled', 'renamer'):
|
if Env.setting('enabled', 'renamer'):
|
||||||
return '.cp(' + movie['library'].get('identifier') + ')' if movie['library'].get('identifier') else ''
|
return '.cp(' + movie['library'].get('identifier') + ')' if movie['library'].get('identifier') else ''
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ class Blackhole(Downloader):
|
|||||||
|
|
||||||
type = ['nzb', 'torrent']
|
type = ['nzb', 'torrent']
|
||||||
|
|
||||||
|
def createFileExtension(self, data = {}, content):
|
||||||
|
if "DOCTYPE nzb" not in content:
|
||||||
|
if data.get('type') == 'nzb':
|
||||||
|
return 'rar'
|
||||||
|
return data.get('type')
|
||||||
|
|
||||||
def download(self, data = {}, movie = {}):
|
def download(self, data = {}, movie = {}):
|
||||||
|
|
||||||
if self.isDisabled() or not self.isCorrectType(data.get('type') or not self.conf('use_for') in ['both', data.get('type')]):
|
if self.isDisabled() or not self.isCorrectType(data.get('type') or not self.conf('use_for') in ['both', data.get('type')]):
|
||||||
@@ -20,15 +26,21 @@ class Blackhole(Downloader):
|
|||||||
if not directory or not os.path.isdir(directory):
|
if not directory or not os.path.isdir(directory):
|
||||||
log.error('No directory set for blackhole %s download.' % data.get('type'))
|
log.error('No directory set for blackhole %s download.' % data.get('type'))
|
||||||
else:
|
else:
|
||||||
fullPath = os.path.join(directory, '%s%s.%s' % (toSafeString(data.get('name')), self.cpTag(movie) , data.get('type')))
|
|
||||||
|
|
||||||
try:
|
|
||||||
if not os.path.isfile(fullPath):
|
|
||||||
log.info('Downloading %s to %s.' % (data.get('type'), fullPath))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
|
file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
|
||||||
|
if "no nzb" in file:
|
||||||
|
log.error('No nzb available!')
|
||||||
|
|
||||||
|
fileExtension = createFileExtension(data, file)
|
||||||
|
fullPath = os.path.join(directory, '%s%s.%s' % (toSafeString(data.get('name')), self.cpTag(movie) , fileExtension)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not os.path.isfile(fullPath):
|
||||||
|
log.info('Downloading %s to %s.' % (data.get('type'), fullPath))
|
||||||
|
except:
|
||||||
|
log.error('Failed to download to blackhole %s' % traceback.format_exc())
|
||||||
|
pass
|
||||||
|
|
||||||
with open(fullPath, 'wb') as f:
|
with open(fullPath, 'wb') as f:
|
||||||
f.write(file)
|
f.write(file)
|
||||||
except:
|
except:
|
||||||
@@ -39,8 +51,4 @@ class Blackhole(Downloader):
|
|||||||
else:
|
else:
|
||||||
log.info('File %s already exists.' % fullPath)
|
log.info('File %s already exists.' % fullPath)
|
||||||
return True
|
return True
|
||||||
except:
|
|
||||||
log.error('Failed to download to blackhole %s' % traceback.format_exc())
|
|
||||||
pass
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
Reference in new issue
Block a user