mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Merge pull request #978 from NigelRook/master
Also check sabnzbd history for nzoid
This commit is contained in:
commit
3c7416ca03
1 changed files with 20 additions and 3 deletions
|
@ -852,6 +852,7 @@ def find_download(clientAgent, download_id):
|
||||||
|
|
||||||
def get_nzoid(inputName):
|
def get_nzoid(inputName):
|
||||||
nzoid = None
|
nzoid = None
|
||||||
|
slots = []
|
||||||
logger.debug("Searching for nzoid from SAbnzbd ...")
|
logger.debug("Searching for nzoid from SAbnzbd ...")
|
||||||
if "http" in core.SABNZBDHOST:
|
if "http" in core.SABNZBDHOST:
|
||||||
baseURL = "%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT)
|
baseURL = "%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT)
|
||||||
|
@ -870,9 +871,25 @@ def get_nzoid(inputName):
|
||||||
try:
|
try:
|
||||||
result = r.json()
|
result = r.json()
|
||||||
cleanName = os.path.splitext(os.path.split(inputName)[1])[0]
|
cleanName = os.path.splitext(os.path.split(inputName)[1])[0]
|
||||||
for slot in result['queue']['slots']:
|
slots.extend([(slot['nzo_id'], slot['filename']) for slot in result['queue']['slots']])
|
||||||
if slot['filename'] in [inputName, cleanName]:
|
except:
|
||||||
nzoid = slot['nzo_id']
|
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)
|
logger.debug("Found nzoid: %s" % nzoid)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue