Merge legacy sab parsing with 0.7.17+

This commit is contained in:
Labrys of Knossos 2022-11-25 00:07:08 -05:00
parent 528cbd02cd
commit 637020d2bf
3 changed files with 25 additions and 48 deletions

View file

@ -89,10 +89,6 @@ __version__ = '12.1.10'
NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual']
TORRENT_CLIENTS = ['transmission', 'deluge', 'utorrent', 'rtorrent', 'qbittorrent', 'other', 'manual']
# sabnzbd constants
SABNZB_NO_OF_ARGUMENTS = 8
SABNZB_0717_NO_OF_ARGUMENTS = 9
# sickbeard fork/branch constants
FORK_DEFAULT = 'default'
FORK_FAILED = 'failed'

View file

@ -3,6 +3,9 @@ import os
from core import logger
from core.processor import nzb
# Constants
MINIMUM_ARGUMENTS = 8
def process_script():
client_agent = 'sabnzbd'
@ -19,49 +22,30 @@ def process_script():
)
def process_legacy(args):
# SABnzbd argv:
# 1 The final directory of the job (full path)
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and '.nzb' removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing.
# 0 = OK
# 1 = failed verification
# 2 = failed unpack
# 3 = 1+2
client_agent = 'sabnzbd'
logger.info('Script triggered from SABnzbd')
def process(args):
"""
SABnzbd arguments:
1. The final directory of the job (full path)
2. The original name of the NZB file
3. Clean version of the job name (no path info and '.nzb' removed)
4. Indexer's report number (if supported)
5. User-defined category
6. Group that the NZB was posted in e.g. alt.binaries.x
7. Status of post processing:
0 = OK
1 = failed verification
2 = failed unpack
3 = 1+2
8. Failure URL
"""
version = '0.7.17+' if len(args) > MINIMUM_ARGUMENTS else ''
logger.info('Script triggered from SABnzbd {}'.format(version))
return nzb.process(
args[1],
input_directory=args[1],
input_name=args[2],
status=int(args[7]),
input_category=args[5],
client_agent=client_agent,
download_id='',
)
def process_0717(args):
# SABnzbd argv:
# 1 The final directory of the job (full path)
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and '.nzb' removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
# 8 Failure URL
client_agent = 'sabnzbd'
logger.info('Script triggered from SABnzbd 0.7.17+')
return nzb.process(
args[1],
input_name=args[2],
status=int(args[7]),
input_category=args[5],
client_agent=client_agent,
client_agent='sabnzbd',
download_id='',
failure_link=''.join(args[8:]),
)

View file

@ -762,11 +762,8 @@ def main(args, section=None):
elif 'SAB_SCRIPT' in os.environ:
result = sab.process_script()
# SABnzbd Pre 0.7.17
elif len(args) == core.SABNZB_NO_OF_ARGUMENTS:
result = sab.process_legacy(args)
# SABnzbd 0.7.17+
elif len(args) >= core.SABNZB_0717_NO_OF_ARGUMENTS:
result = sab.process_0717(args)
elif len(args) >= sab.MINIMUM_ARGUMENTS:
result = sab.process(args)
# Generic program
elif len(args) > 5 and args[5] == 'generic':
logger.info('Script triggered from generic program')