Also check sabnzbd history for nzoid

This commit is contained in:
Nigel Rook 2016-02-28 23:54:34 +00:00
commit 3155f9493a

View file

@ -824,6 +824,7 @@ def find_download(clientAgent, download_id):
def get_nzoid(inputName):
nzoid = None
slots = []
logger.debug("Searching for nzoid from SAbnzbd ...")
if "http" in core.SABNZBDHOST:
baseURL = "%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT)
@ -842,9 +843,25 @@ def get_nzoid(inputName):
try:
result = r.json()
cleanName = os.path.splitext(os.path.split(inputName)[1])[0]
for slot in result['queue']['slots']:
if slot['filename'] in [inputName, cleanName]:
nzoid = slot['nzo_id']
slots.extend([(slot['nzo_id'], slot['filename']) for slot in result['queue']['slots']])
except:
logger.warning("Data from SABnzbd queue could not be parsed")
params['mode'] = "history"
try:
r = requests.get(url, params=params, verify=False, timeout=(30, 120))
except requests.ConnectionError:
logger.error("Unable to open URL")
return nzoid # failure
try:
result = r.json()
cleanName = os.path.splitext(os.path.split(inputName)[1])[0]
slots.extend([(slot['nzo_id'], slot['name']) for slot in result['history']['slots']])
except:
logger.warning("Data from SABnzbd history could not be parsed")
try:
for nzo_id, name in slots:
if name in [inputName, cleanName]:
nzoid = nzo_id
logger.debug("Found nzoid: %s" % nzoid)
break
except: