mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
Extract sabnzb processing from nzbToMedia.main
-> core.processor.sabnzbd
This commit is contained in:
parent
073b19034b
commit
58c998712f
2 changed files with 71 additions and 31 deletions
67
core/processor/sab.py
Normal file
67
core/processor/sab.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from core import logger
|
||||||
|
from core.processor import nzb
|
||||||
|
|
||||||
|
|
||||||
|
def process_script():
|
||||||
|
client_agent = 'sabnzbd'
|
||||||
|
logger.info('Script triggered from SABnzbd Version {0}.'.format(
|
||||||
|
os.environ['SAB_VERSION']))
|
||||||
|
return nzb.process(
|
||||||
|
os.environ['SAB_COMPLETE_DIR'],
|
||||||
|
input_name=os.environ['SAB_FINAL_NAME'],
|
||||||
|
status=int(os.environ['SAB_PP_STATUS']),
|
||||||
|
client_agent=client_agent,
|
||||||
|
download_id=os.environ['SAB_NZO_ID'],
|
||||||
|
input_category=os.environ['SAB_CAT'],
|
||||||
|
failure_link=os.environ['SAB_FAILURE_URL'],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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')
|
||||||
|
return nzb.process(
|
||||||
|
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,
|
||||||
|
download_id='',
|
||||||
|
failure_link=''.join(args[8:]),
|
||||||
|
)
|
|
@ -733,7 +733,7 @@ cleanup.clean(cleanup.FOLDER_STRUCTURE)
|
||||||
|
|
||||||
import core
|
import core
|
||||||
from core import logger
|
from core import logger
|
||||||
from core.processor import nzbget
|
from core.processor import nzbget, sab
|
||||||
from core.processor.nzb import process
|
from core.processor.nzb import process
|
||||||
from core.auto_process.common import ProcessResult
|
from core.auto_process.common import ProcessResult
|
||||||
from core.utils import (
|
from core.utils import (
|
||||||
|
@ -769,40 +769,13 @@ def main(args, section=None):
|
||||||
result = nzbget.process()
|
result = nzbget.process()
|
||||||
# SABnzbd
|
# SABnzbd
|
||||||
elif 'SAB_SCRIPT' in os.environ:
|
elif 'SAB_SCRIPT' in os.environ:
|
||||||
client_agent = 'sabnzbd'
|
result = sab.process_script()
|
||||||
logger.info('Script triggered from SABnzbd Version {0}.'.format(os.environ['SAB_VERSION']))
|
|
||||||
result = process(os.environ['SAB_COMPLETE_DIR'], input_name=os.environ['SAB_FINAL_NAME'], status=int(os.environ['SAB_PP_STATUS']),
|
|
||||||
client_agent=client_agent, download_id=os.environ['SAB_NZO_ID'], input_category=os.environ['SAB_CAT'],
|
|
||||||
failure_link=os.environ['SAB_FAILURE_URL'])
|
|
||||||
# SABnzbd Pre 0.7.17
|
# SABnzbd Pre 0.7.17
|
||||||
elif len(args) == core.SABNZB_NO_OF_ARGUMENTS:
|
elif len(args) == core.SABNZB_NO_OF_ARGUMENTS:
|
||||||
# SABnzbd argv:
|
result = sab.process_legacy(args)
|
||||||
# 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')
|
|
||||||
result = process(args[1], input_name=args[2], status=int(args[7]), input_category=args[5], client_agent=client_agent,
|
|
||||||
download_id='')
|
|
||||||
# SABnzbd 0.7.17+
|
# SABnzbd 0.7.17+
|
||||||
elif len(args) >= core.SABNZB_0717_NO_OF_ARGUMENTS:
|
elif len(args) >= core.SABNZB_0717_NO_OF_ARGUMENTS:
|
||||||
# SABnzbd argv:
|
result = sab.process_0717(args)
|
||||||
# 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+')
|
|
||||||
result = process(args[1], input_name=args[2], status=int(args[7]), input_category=args[5], client_agent=client_agent,
|
|
||||||
download_id='', failure_link=''.join(args[8:]))
|
|
||||||
# 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')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue