Added config options
This commit is contained in:
@@ -35,11 +35,25 @@ config = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'manual',
|
'name': 'manual',
|
||||||
'default': 0,
|
'default': False,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'advanced': True,
|
'advanced': True,
|
||||||
'description': 'Disable this downloader for automated searches, but use it when I manually send a release.',
|
'description': 'Disable this downloader for automated searches, but use it when I manually send a release.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'download failed',
|
||||||
|
'default': True,
|
||||||
|
'type': 'bool',
|
||||||
|
'advanced': True,
|
||||||
|
'description': 'Try next the next best release for a movie after a download failed.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'delete failed',
|
||||||
|
'default': True,
|
||||||
|
'type': 'bool',
|
||||||
|
'advanced': True,
|
||||||
|
'description': 'Delete a release after it\'s download failed.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ from couchpotato.core.helpers.encoding import tryUrlencode
|
|||||||
from couchpotato.core.helpers.variable import cleanHost
|
from couchpotato.core.helpers.variable import cleanHost
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
import traceback
|
import traceback
|
||||||
import urllib2
|
|
||||||
import requests
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
@@ -69,6 +67,9 @@ class Sabnzbd(Downloader):
|
|||||||
if self.isDisabled(manual = True) or not self.isCorrectType(data.get('type')):
|
if self.isDisabled(manual = True) or not self.isCorrectType(data.get('type')):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not self.conf('download failed', default = True):
|
||||||
|
return False
|
||||||
|
|
||||||
log.info('Checking download status of "%s" at SABnzbd.', data.get('name'))
|
log.info('Checking download status of "%s" at SABnzbd.', data.get('name'))
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
@@ -80,7 +81,7 @@ class Sabnzbd(Downloader):
|
|||||||
log.debug('Opening: %s', url)
|
log.debug('Opening: %s', url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
history = json.load(urllib2.urlopen(url))
|
history = json.load(self.urlopen(url))
|
||||||
except:
|
except:
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
@@ -91,23 +92,24 @@ class Sabnzbd(Downloader):
|
|||||||
for slot in history['history']['slots']:
|
for slot in history['history']['slots']:
|
||||||
log.debug('Found %s in SabNZBd history, which has %s', (slot['name'], slot['status']))
|
log.debug('Found %s in SabNZBd history, which has %s', (slot['name'], slot['status']))
|
||||||
if slot['name'] == nzbname and slot['status'] == 'Failed':
|
if slot['name'] == nzbname and slot['status'] == 'Failed':
|
||||||
log.debug('%s failed downloading, deleting...', slot['name'])
|
|
||||||
|
|
||||||
# Delete failed download
|
# Delete failed download
|
||||||
params = {
|
if self.conf('delete failed', default = True):
|
||||||
'apikey': self.conf('api_key'),
|
log.info('%s failed downloading, deleting...', slot['name'])
|
||||||
'mode': 'history',
|
params = {
|
||||||
'name': 'delete',
|
'apikey': self.conf('api_key'),
|
||||||
'del_files': '1',
|
'mode': 'history',
|
||||||
'value': slot['nzo_id']
|
'name': 'delete',
|
||||||
}
|
'del_files': '1',
|
||||||
url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params)
|
'value': slot['nzo_id']
|
||||||
try:
|
}
|
||||||
data = self.urlopen(url, timeout = 60, show_error = False)
|
url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params)
|
||||||
except:
|
try:
|
||||||
log.error(traceback.format_exc())
|
data = self.urlopen(url, timeout = 60, show_error = False)
|
||||||
|
except:
|
||||||
|
log.error(traceback.format_exc())
|
||||||
|
|
||||||
# Return failed
|
# Return download failed
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user