mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Added SiCKRAGE API support for post-processing
This commit is contained in:
parent
ee243fbba5
commit
5f2a5499b8
4 changed files with 59 additions and 26 deletions
|
@ -107,6 +107,7 @@
|
||||||
enabled = 0
|
enabled = 0
|
||||||
host = localhost
|
host = localhost
|
||||||
port = 8081
|
port = 8081
|
||||||
|
apikey =
|
||||||
username =
|
username =
|
||||||
password =
|
password =
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import itertools
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -63,6 +64,7 @@ FORK_FAILED = "failed"
|
||||||
FORK_FAILED_TORRENT = "failed-torrent"
|
FORK_FAILED_TORRENT = "failed-torrent"
|
||||||
FORK_SICKRAGETV = "sickragetv"
|
FORK_SICKRAGETV = "sickragetv"
|
||||||
FORK_SICKRAGE = "sickrage"
|
FORK_SICKRAGE = "sickrage"
|
||||||
|
FORK_SICKRAGE_API = "sickrage-api"
|
||||||
FORK_MEDUSA = "medusa"
|
FORK_MEDUSA = "medusa"
|
||||||
FORK_SICKGEAR = "sickgear"
|
FORK_SICKGEAR = "sickgear"
|
||||||
FORKS[FORK_DEFAULT] = {"dir": None}
|
FORKS[FORK_DEFAULT] = {"dir": None}
|
||||||
|
@ -70,10 +72,10 @@ FORKS[FORK_FAILED] = {"dirName": None, "failed": None}
|
||||||
FORKS[FORK_FAILED_TORRENT] = {"dir": None, "failed": None, "process_method": None}
|
FORKS[FORK_FAILED_TORRENT] = {"dir": None, "failed": None, "process_method": None}
|
||||||
FORKS[FORK_SICKRAGETV] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None}
|
FORKS[FORK_SICKRAGETV] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None}
|
||||||
FORKS[FORK_SICKRAGE] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "force_next": None}
|
FORKS[FORK_SICKRAGE] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "force_next": None}
|
||||||
|
FORKS[FORK_SICKRAGE_API] = {"path": None, "failed": None, "process_method": None, "force_replace": None, "return_data": None, "type": None, "delete": None, "force_next": None}
|
||||||
FORKS[FORK_MEDUSA] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs":None}
|
FORKS[FORK_MEDUSA] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs":None}
|
||||||
FORKS[FORK_SICKGEAR] = {"dir": None, "failed": None, "process_method": None, "force": None}
|
FORKS[FORK_SICKGEAR] = {"dir": None, "failed": None, "process_method": None, "force": None}
|
||||||
ALL_FORKS = {"dir": None, "dirName": None, "proc_dir": None, "process_directory": None, "failed": None, "process_method": None, "force": None,
|
ALL_FORKS = {k:None for k in set(list(itertools.chain.from_iterable([FORKS[x].keys() for x in FORKS.keys()])))}
|
||||||
"delete_on": None, "ignore_subs": None, "force_next": None}
|
|
||||||
|
|
||||||
# NZBGet Exit Codes
|
# NZBGet Exit Codes
|
||||||
NZBGET_POSTPROCESS_PARCHECK = 92
|
NZBGET_POSTPROCESS_PARCHECK = 92
|
||||||
|
@ -246,10 +248,10 @@ def initialize(section=None):
|
||||||
if not makeDir(LOG_DIR):
|
if not makeDir(LOG_DIR):
|
||||||
print("No log folder, logging to screen only")
|
print("No log folder, logging to screen only")
|
||||||
|
|
||||||
MYAPP = RunningProcess()
|
#MYAPP = RunningProcess()
|
||||||
while MYAPP.alreadyrunning():
|
#while MYAPP.alreadyrunning():
|
||||||
print("Waiting for existing session to end")
|
# print("Waiting for existing session to end")
|
||||||
time.sleep(30)
|
# time.sleep(30)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_ALL, "")
|
locale.setlocale(locale.LC_ALL, "")
|
||||||
|
|
|
@ -189,8 +189,19 @@ class autoProcessTV(object):
|
||||||
if param == "failed":
|
if param == "failed":
|
||||||
fork_params[param] = failed
|
fork_params[param] = failed
|
||||||
del fork_params['proc_type']
|
del fork_params['proc_type']
|
||||||
|
if "type" in fork_params:
|
||||||
|
del fork_params['type']
|
||||||
|
|
||||||
if param in ["dirName", "dir", "proc_dir", "process_directory"]:
|
if param == "return_data":
|
||||||
|
fork_params[param] = 0
|
||||||
|
del fork_params['quiet']
|
||||||
|
|
||||||
|
if param == "type":
|
||||||
|
fork_params[param] = 'manual'
|
||||||
|
if "proc_type" in fork_params:
|
||||||
|
del fork_params['proc_type']
|
||||||
|
|
||||||
|
if param in ["dirName", "dir", "proc_dir", "process_directory", "path"]:
|
||||||
fork_params[param] = dirName
|
fork_params[param] = dirName
|
||||||
if remote_path:
|
if remote_path:
|
||||||
fork_params[param] = remoteDir(dirName)
|
fork_params[param] = remoteDir(dirName)
|
||||||
|
@ -201,13 +212,13 @@ class autoProcessTV(object):
|
||||||
else:
|
else:
|
||||||
del fork_params[param]
|
del fork_params[param]
|
||||||
|
|
||||||
if param == "force":
|
if param in ["force", "force_replace"]:
|
||||||
if force:
|
if force:
|
||||||
fork_params[param] = force
|
fork_params[param] = force
|
||||||
else:
|
else:
|
||||||
del fork_params[param]
|
del fork_params[param]
|
||||||
|
|
||||||
if param == "delete_on":
|
if param in ["delete_on", "delete"]:
|
||||||
if delete_on:
|
if delete_on:
|
||||||
fork_params[param] = delete_on
|
fork_params[param] = delete_on
|
||||||
else:
|
else:
|
||||||
|
@ -248,6 +259,9 @@ class autoProcessTV(object):
|
||||||
|
|
||||||
url = None
|
url = None
|
||||||
if section == "SickBeard":
|
if section == "SickBeard":
|
||||||
|
if apikey:
|
||||||
|
url = "{0}{1}:{2}{3}/api/{4}/?cmd=postprocess".format(protocol, host, port, web_root, apikey)
|
||||||
|
else:
|
||||||
url = "{0}{1}:{2}{3}/home/postprocess/processEpisode".format(protocol, host, port, web_root)
|
url = "{0}{1}:{2}{3}/home/postprocess/processEpisode".format(protocol, host, port, web_root)
|
||||||
elif section == "NzbDrone":
|
elif section == "NzbDrone":
|
||||||
url = "{0}{1}:{2}{3}/api/command".format(protocol, host, port, web_root)
|
url = "{0}{1}:{2}{3}/api/command".format(protocol, host, port, web_root)
|
||||||
|
@ -268,6 +282,7 @@ class autoProcessTV(object):
|
||||||
if section == "SickBeard":
|
if section == "SickBeard":
|
||||||
logger.debug("Opening URL: {0} with params: {1}".format(url, fork_params), section)
|
logger.debug("Opening URL: {0} with params: {1}".format(url, fork_params), section)
|
||||||
s = requests.Session()
|
s = requests.Session()
|
||||||
|
if not apikey:
|
||||||
login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root)
|
login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root)
|
||||||
login_params = {'username': username, 'password': password}
|
login_params = {'username': username, 'password': password}
|
||||||
s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60))
|
s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60))
|
||||||
|
@ -287,6 +302,10 @@ class autoProcessTV(object):
|
||||||
Queued = False
|
Queued = False
|
||||||
Started = False
|
Started = False
|
||||||
if section == "SickBeard":
|
if section == "SickBeard":
|
||||||
|
if apikey:
|
||||||
|
if r.json()['result'] == 'success':
|
||||||
|
Success = True
|
||||||
|
else:
|
||||||
for line in r.iter_lines():
|
for line in r.iter_lines():
|
||||||
if line:
|
if line:
|
||||||
logger.postprocess("{0}".format(line), section)
|
logger.postprocess("{0}".format(line), section)
|
||||||
|
@ -296,6 +315,7 @@ class autoProcessTV(object):
|
||||||
Queued = True
|
Queued = True
|
||||||
if "Processing succeeded" in line or "Successfully processed" in line:
|
if "Processing succeeded" in line or "Successfully processed" in line:
|
||||||
Success = True
|
Success = True
|
||||||
|
|
||||||
if Queued:
|
if Queued:
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
elif section == "NzbDrone":
|
elif section == "NzbDrone":
|
||||||
|
|
|
@ -52,8 +52,14 @@ def autoFork(section, inputCategory):
|
||||||
logger.info("Attempting to auto-detect {category} fork".format(category=inputCategory))
|
logger.info("Attempting to auto-detect {category} fork".format(category=inputCategory))
|
||||||
# define the order to test. Default must be first since the default fork doesn't reject parameters.
|
# define the order to test. Default must be first since the default fork doesn't reject parameters.
|
||||||
# then in order of most unique parameters.
|
# then in order of most unique parameters.
|
||||||
|
|
||||||
|
if apikey:
|
||||||
|
url = "{protocol}{host}:{port}{root}/api/{apikey}/?cmd=help&subject=postprocess".format(
|
||||||
|
protocol=protocol, host=host, port=port, root=web_root, apikey=apikey)
|
||||||
|
else:
|
||||||
url = "{protocol}{host}:{port}{root}/home/postprocess/".format(
|
url = "{protocol}{host}:{port}{root}/home/postprocess/".format(
|
||||||
protocol=protocol, host=host, port=port, root=web_root)
|
protocol=protocol, host=host, port=port, root=web_root)
|
||||||
|
|
||||||
# attempting to auto-detect fork
|
# attempting to auto-detect fork
|
||||||
try:
|
try:
|
||||||
if username and password:
|
if username and password:
|
||||||
|
@ -71,7 +77,11 @@ def autoFork(section, inputCategory):
|
||||||
r = []
|
r = []
|
||||||
if r and r.ok:
|
if r and r.ok:
|
||||||
for param in params:
|
for param in params:
|
||||||
if not 'name="{param}"'.format(param=param) in r.text:
|
if apikey:
|
||||||
|
if param not in r.json()['data']['optionalParameters'].keys():
|
||||||
|
rem_params.append(param)
|
||||||
|
else:
|
||||||
|
if 'name="{param}"'.format(param=param) not in r.text:
|
||||||
rem_params.append(param)
|
rem_params.append(param)
|
||||||
for param in rem_params:
|
for param in rem_params:
|
||||||
params.pop(param)
|
params.pop(param)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue