Browse Source

Install support for X-Failure call-back URL.

To be called when par2 verification fails, the RAR files have CRC errors or the right password isn't known.
pull/162/head
shypike 11 years ago
parent
commit
470c1fc13e
  1. 2
      sabnzbd/cfg.py
  2. 2
      sabnzbd/interface.py
  3. 12
      sabnzbd/newsunpack.py
  4. 20
      sabnzbd/postproc.py

2
sabnzbd/cfg.py

@ -268,6 +268,8 @@ history_limit = OptionNumber('misc', 'history_limit', 50, 0)
show_sysload = OptionNumber('misc', 'show_sysload', 2, 0, 2)
web_watchdog = OptionBool('misc', 'web_watchdog', False)
warn_dupl_jobs = OptionBool('misc', 'warn_dupl_jobs', True)
new_nzb_on_failure = OptionBool('misc', 'new_nzb_on_failure', True)
#------------------------------------------------------------------------------
# Set root folders for Folder config-items

2
sabnzbd/interface.py

@ -1266,7 +1266,7 @@ SPECIAL_BOOL_LIST = \
'osx_menu', 'osx_speed', 'win_menu', 'uniconfig', 'use_pickle', 'allow_incomplete_nzb',
'randomize_server_ip', 'no_ipv6', 'keep_awake', 'overwrite_files', 'empty_postproc',
'web_watchdog', 'wait_for_dfolder', 'warn_empty_nzb', 'enable_recursive', 'sanitize_safe',
'enable_meta', 'flat_unpack', 'warn_dupl_jobs'
'enable_meta', 'flat_unpack', 'warn_dupl_jobs', 'new_nzb_on_failure'
)
SPECIAL_VALUE_LIST = \
( 'size_limit', 'folder_max_length', 'fsys_type', 'movie_rename_limit', 'nomedia_marker',

12
sabnzbd/newsunpack.py

@ -191,7 +191,7 @@ def unpack_magic(nzo, workdir, workdir_complete, dele, one_folder, joinables, zi
rerun = False
newfiles = []
error = False
error = 0
if cfg.enable_filejoin():
new_joins = [jn for jn in xjoinables if jn not in joinables]
@ -221,7 +221,7 @@ def unpack_magic(nzo, workdir, workdir_complete, dele, one_folder, joinables, zi
rerun = True
logging.info('Unzip starting on %s', workdir)
if unzip(nzo, workdir, workdir_complete, dele, one_folder, new_zips):
error = True
error = 1
logging.info('Unzip finished on %s', workdir)
nzo.set_action_line()
@ -463,7 +463,7 @@ def rar_unpack(nzo, workdir, workdir_complete, delete, one_folder, rars):
except OSError:
logging.warning(Ta('Deleting %s failed!'), latin1(brokenrar))
return not success, extracted_files
return fail, extracted_files
def rar_extract(rarfile, numrars, one_folder, nzo, setname, extraction_path):
@ -522,7 +522,7 @@ def rar_extract(rarfile, numrars, one_folder, nzo, setname, extraction_path):
def rar_extract_core(rarfile, numrars, one_folder, nzo, setname, extraction_path, password):
""" Unpack single rar set 'rarfile' to 'extraction_path'
Return fail==0(ok)/fail==1(error)/fail==2(wrong password), new_files, rars
Return fail==0(ok)/fail==1(error)/fail==2(wrong password)/fail==3(crc-error), new_files, rars
"""
start = time()
@ -617,7 +617,7 @@ def rar_extract_core(rarfile, numrars, one_folder, nzo, setname, extraction_path
msg = ('[%s] '+Ta('ERROR: CRC failed in "%s"')) % (setname, latin1(filename))
nzo.set_unpack_info('Unpack', unicoder(msg), set=setname)
logging.warning(Ta('ERROR: CRC failed in "%s"'), latin1(setname))
fail = 1
fail = 3
elif line.startswith('Write error'):
nzo.fail_msg = T('Unpacking failed, write error or disk is full?')
@ -675,7 +675,7 @@ def rar_extract_core(rarfile, numrars, one_folder, nzo, setname, extraction_path
nzo.fail_msg = T('Unusable RAR file')
msg = ('[%s][%s] '+ Ta('Unusable RAR file')) % (setname, latin1(filename))
nzo.set_unpack_info('Unpack', unicoder(msg), set=setname)
fail = 1
fail = 3
else:
m = re.search(r'^(Extracting|Creating|...)\s+(.*?)\s+OK\s*$', line)

20
sabnzbd/postproc.py

@ -241,7 +241,8 @@ def process_job(nzo):
nzo.status = Status.FAILED
nzo.save_attribs()
all_ok = False
par_error = unpack_error = True
par_error = True
unpack_error = 1
try:
@ -271,7 +272,8 @@ def process_job(nzo):
flag_repair = flag_unpack = False
all_ok = cfg.empty_postproc() and empty
if not all_ok:
par_error = unpack_error = True
par_error = True
unpack_error = 1
script = nzo.script
cat = nzo.cat
@ -411,7 +413,7 @@ def process_job(nzo):
if empty:
job_result = -1
else:
job_result = int(par_error) + int(unpack_error)*2
job_result = int(par_error) + int(bool(unpack_error))*2
if cfg.ignore_samples() > 0:
remove_samples(workdir_complete)
@ -437,7 +439,7 @@ def process_job(nzo):
script_log, script_ret = external_processing(script_path, workdir_complete, nzo.filename,
msgid, dirname, cat, nzo.group, job_result,
nzo.nzo_info.get('failure', ''))
script_line = get_last_line(script_log)
script_line = get_last_line(script_log)
if script_log:
script_output = nzo.nzo_id
if script_line:
@ -550,6 +552,10 @@ def process_job(nzo):
logging.error(Ta('Error removing workdir (%s)'), workdir)
logging.info("Traceback: ", exc_info = True)
# Use automatic retry link on par2 errors and encrypted/bad RARs
if par_error or unpack_error in (2, 3):
try_alt_nzb(nzo)
return True
@ -832,3 +838,9 @@ def remove_from_list(name, lst):
logging.debug('Popping %s', lst[n])
lst.pop(n)
return
def try_alt_nzb(nzo):
""" Try to get a new NZB if available """
url = nzo.nzo_info.get('failure')
if url and cfg.new_nzb_on_failure():
sabnzbd.add_url(url, nzo.pp, nzo.script, nzo.cat, nzo.priority)

Loading…
Cancel
Save