Added SiCKRAGE API support for post-processing

This commit is contained in:
echel0n 2018-06-21 19:53:48 -07:00
parent ee243fbba5
commit 5f2a5499b8
4 changed files with 59 additions and 26 deletions

View file

@ -189,8 +189,19 @@ class autoProcessTV(object):
if param == "failed":
fork_params[param] = failed
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
if remote_path:
fork_params[param] = remoteDir(dirName)
@ -201,13 +212,13 @@ class autoProcessTV(object):
else:
del fork_params[param]
if param == "force":
if param in ["force", "force_replace"]:
if force:
fork_params[param] = force
else:
del fork_params[param]
if param == "delete_on":
if param in ["delete_on", "delete"]:
if delete_on:
fork_params[param] = delete_on
else:
@ -248,7 +259,10 @@ class autoProcessTV(object):
url = None
if section == "SickBeard":
url = "{0}{1}:{2}{3}/home/postprocess/processEpisode".format(protocol, host, port, web_root)
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)
elif section == "NzbDrone":
url = "{0}{1}:{2}{3}/api/command".format(protocol, host, port, web_root)
url2 = "{0}{1}:{2}{3}/api/config/downloadClient".format(protocol, host, port, web_root)
@ -268,9 +282,10 @@ class autoProcessTV(object):
if section == "SickBeard":
logger.debug("Opening URL: {0} with params: {1}".format(url, fork_params), section)
s = requests.Session()
login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root)
login_params = {'username': username, 'password': password}
s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60))
if not apikey:
login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root)
login_params = {'username': username, 'password': password}
s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60))
r = s.get(url, auth=(username, password), params=fork_params, stream=True, verify=False, timeout=(30, 1800))
elif section == "NzbDrone":
logger.debug("Opening URL: {0} with data: {1}".format(url, data), section)
@ -287,15 +302,20 @@ class autoProcessTV(object):
Queued = False
Started = False
if section == "SickBeard":
for line in r.iter_lines():
if line:
logger.postprocess("{0}".format(line), section)
if "Moving file from" in line:
inputName = os.path.split(line)[1]
if "added to the queue" in line:
Queued = True
if "Processing succeeded" in line or "Successfully processed" in line:
Success = True
if apikey:
if r.json()['result'] == 'success':
Success = True
else:
for line in r.iter_lines():
if line:
logger.postprocess("{0}".format(line), section)
if "Moving file from" in line:
inputName = os.path.split(line)[1]
if "added to the queue" in line:
Queued = True
if "Processing succeeded" in line or "Successfully processed" in line:
Success = True
if Queued:
time.sleep(60)
elif section == "NzbDrone":