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'] NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual']
TORRENT_CLIENTS = ['transmission', 'deluge', 'utorrent', 'rtorrent', 'qbittorrent', 'other', '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 # sickbeard fork/branch constants
FORK_DEFAULT = 'default' FORK_DEFAULT = 'default'
FORK_FAILED = 'failed' FORK_FAILED = 'failed'

View file

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

View file

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