mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
update to use Mylar api. Fixes #1374
This commit is contained in:
parent
003febeafe
commit
93b4fbf0e1
5 changed files with 25 additions and 25 deletions
|
@ -232,8 +232,7 @@
|
||||||
enabled = 0
|
enabled = 0
|
||||||
host = localhost
|
host = localhost
|
||||||
port= 8090
|
port= 8090
|
||||||
username=
|
apikey=
|
||||||
password=
|
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
web_root=
|
web_root=
|
||||||
ssl=0
|
ssl=0
|
||||||
|
|
|
@ -12,22 +12,21 @@ requests.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
class autoProcessComics(object):
|
class autoProcessComics(object):
|
||||||
def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None):
|
def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None):
|
||||||
if int(status) != 0:
|
|
||||||
logger.warning("FAILED DOWNLOAD DETECTED, nothing to process.", section)
|
apc_version = "2.04"
|
||||||
return [1, "{0}: Failed to post-process. {1} does not support failed downloads".format(section, section)]
|
comicrn_version = "1.01"
|
||||||
|
|
||||||
cfg = dict(core.CFG[section][inputCategory])
|
cfg = dict(core.CFG[section][inputCategory])
|
||||||
|
|
||||||
host = cfg["host"]
|
host = cfg["host"]
|
||||||
port = cfg["port"]
|
port = cfg["port"]
|
||||||
username = cfg["username"]
|
apikey = cfg["apikey"]
|
||||||
password = cfg["password"]
|
|
||||||
ssl = int(cfg.get("ssl", 0))
|
ssl = int(cfg.get("ssl", 0))
|
||||||
web_root = cfg.get("web_root", "")
|
web_root = cfg.get("web_root", "")
|
||||||
remote_path = int(cfg.get("remote_path"), 0)
|
remote_path = int(cfg.get("remote_path"), 0)
|
||||||
protocol = "https://" if ssl else "http://"
|
protocol = "https://" if ssl else "http://"
|
||||||
|
|
||||||
url = "{0}{1}:{2}{3}/post_process".format(protocol, host, port, web_root)
|
url = "{0}{1}:{2}{3}/api".format(protocol, host, port, web_root)
|
||||||
if not server_responding(url):
|
if not server_responding(url):
|
||||||
logger.error("Server did not respond. Exiting", section)
|
logger.error("Server did not respond. Exiting", section)
|
||||||
return [1, "{0}: Failed to post-process - {1} did not respond.".format(section, section)]
|
return [1, "{0}: Failed to post-process - {1} did not respond.".format(section, section)]
|
||||||
|
@ -38,30 +37,38 @@ class autoProcessComics(object):
|
||||||
inputName = clean_name
|
inputName = clean_name
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
'cmd': 'forceProcess',
|
||||||
|
'apikey': apikey,
|
||||||
'nzb_folder': remoteDir(dirName) if remote_path else dirName,
|
'nzb_folder': remoteDir(dirName) if remote_path else dirName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if inputName is not None:
|
if inputName is not None:
|
||||||
params['nzb_name'] = inputName
|
params['nzb_name'] = inputName
|
||||||
|
params['failed'] = int(status)
|
||||||
|
params['apc_version'] = apc_version
|
||||||
|
params['comicrn_version'] = comicrn_version
|
||||||
|
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
logger.debug("Opening URL: {0}".format(url), section)
|
logger.debug("Opening URL: {0}".format(url), section)
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, auth=(username, password), params=params, stream=True, verify=False, timeout=(30, 300))
|
r = requests.post(url, params=params, stream=True, verify=False, timeout=(30, 300))
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
logger.error("Unable to open URL", section)
|
logger.error("Unable to open URL", section)
|
||||||
return [1, "{0}: Failed to post-process - Unable to connect to {1}".format(section, section)]
|
return [1, "{0}: Failed to post-process - Unable to connect to {1}".format(section, section)]
|
||||||
for line in r.iter_lines():
|
if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
|
||||||
|
logger.error("Server returned status {0}".format(r.status_code), section)
|
||||||
|
return [1, "{0}: Failed to post-process - Server returned status {1}".format(section, r.status_code)]
|
||||||
|
|
||||||
|
result = r.content
|
||||||
|
if not type(result) == list:
|
||||||
|
result = result.split('\n')
|
||||||
|
for line in result:
|
||||||
if line:
|
if line:
|
||||||
logger.postprocess("{0}".format(line), section)
|
logger.postprocess("{0}".format(line), section)
|
||||||
if "Post Processing SUCCESSFUL" in line:
|
if "Post Processing SUCCESSFUL" in line:
|
||||||
success = True
|
success = True
|
||||||
|
|
||||||
if r.status_code not in [requests.codes.ok, requests.codes.created, requests.codes.accepted]:
|
|
||||||
logger.error("Server returned status {0}".format(r.status_code), section)
|
|
||||||
return [1, "{0}: Failed to post-process - Server returned status {1}".format(section, r.status_code)]
|
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
logger.postprocess("SUCCESS: This issue has been processed successfully", section)
|
logger.postprocess("SUCCESS: This issue has been processed successfully", section)
|
||||||
return [0, "{0}: Successfully post-processed {1}".format(section, inputName)]
|
return [0, "{0}: Successfully post-processed {1}".format(section, inputName)]
|
||||||
|
|
|
@ -157,7 +157,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
||||||
if option == ['outputDirectory']:
|
if option == ['outputDirectory']:
|
||||||
CFG_NEW['Torrent'][option] = os.path.split(os.path.normpath(value))[0]
|
CFG_NEW['Torrent'][option] = os.path.split(os.path.normpath(value))[0]
|
||||||
values.pop(option)
|
values.pop(option)
|
||||||
if section in ['CouchPotato', 'HeadPhones', 'Gamez']:
|
if section in ['CouchPotato', 'HeadPhones', 'Gamez', 'Mylar']:
|
||||||
if option in ['username', 'password']:
|
if option in ['username', 'password']:
|
||||||
values.pop(option)
|
values.pop(option)
|
||||||
if section in ["SickBeard", "Mylar"]:
|
if section in ["SickBeard", "Mylar"]:
|
||||||
|
|
|
@ -341,11 +341,8 @@
|
||||||
# Mylar port.
|
# Mylar port.
|
||||||
#myport=8090
|
#myport=8090
|
||||||
|
|
||||||
# Mylar username.
|
# Mylar api key.
|
||||||
#myusername=
|
#myapikey=
|
||||||
|
|
||||||
# Mylar password.
|
|
||||||
#mypassword=
|
|
||||||
|
|
||||||
# Mylar uses ssl (0, 1).
|
# Mylar uses ssl (0, 1).
|
||||||
#
|
#
|
||||||
|
|
|
@ -41,11 +41,8 @@
|
||||||
# Mylar port.
|
# Mylar port.
|
||||||
#myport=8090
|
#myport=8090
|
||||||
|
|
||||||
# Mylar username.
|
# Mylar api key.
|
||||||
#myusername=
|
#myapikey=
|
||||||
|
|
||||||
# Mylar password.
|
|
||||||
#mypassword=
|
|
||||||
|
|
||||||
# Mylar uses ssl (0, 1).
|
# Mylar uses ssl (0, 1).
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue