mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 06:13:19 -07:00
Only check syno api when input name passed, and use torrent id to limit results. #1671
This commit is contained in:
parent
b79c959022
commit
77650aa80b
1 changed files with 11 additions and 4 deletions
|
@ -89,19 +89,26 @@ def parse_synods(args):
|
||||||
input_category = ''
|
input_category = ''
|
||||||
input_name = os.getenv('TR_TORRENT_NAME')
|
input_name = os.getenv('TR_TORRENT_NAME')
|
||||||
input_hash = os.getenv('TR_TORRENT_HASH')
|
input_hash = os.getenv('TR_TORRENT_HASH')
|
||||||
res = core.TORRENT_CLASS.tasks_list(additional_param='detail')
|
if not input_name: # No info passed. Assume manual download.
|
||||||
|
return input_directory, input_name, input_category, input_hash, input_id
|
||||||
|
input_id = 'dbid_'.format(os.getenv('TR_TORRENT_ID'))
|
||||||
|
#res = core.TORRENT_CLASS.tasks_list(additional_param='detail')
|
||||||
|
res = core.TORRENT_CLASS.tasks_info(input_id, additional_param='detail')
|
||||||
logger.debug('result from syno {0}'.format(res))
|
logger.debug('result from syno {0}'.format(res))
|
||||||
if res['success']:
|
if res['success']:
|
||||||
try:
|
try:
|
||||||
tasks = res['data']['tasks']
|
tasks = res['data']['tasks']
|
||||||
task = [ task for task in tasks if task['title'] == input_name ][0]
|
task = [ task for task in tasks if task['id'] == input_id ][0]
|
||||||
input_id = task['id']
|
input_id = task['id']
|
||||||
input_directory = task['additional']['detail']['destination']
|
input_directory = task['additional']['detail']['destination']
|
||||||
except:
|
except:
|
||||||
logger.error('unable to find download details in Synology DS')
|
logger.error('unable to find download details in Synology DS')
|
||||||
#Syno paths appear to be relative. Let's test to see if the returned path exists, and if not append to /volume1/
|
#Syno paths appear to be relative. Let's test to see if the returned path exists, and if not append to /volume1/
|
||||||
if not os.path.isdir(input_directory) and os.path.isdir(os.path.join('/volume1/', input_directory)):
|
if not os.path.isdir(input_directory):
|
||||||
input_directory = os.path.join('/volume1/', input_directory)
|
for root in ['/volume1/', '/volume2/', '/volume3/', '/volume4/']:
|
||||||
|
if os.path.isdir(os.path.join(root, input_directory)):
|
||||||
|
input_directory = os.path.join(root, input_directory)
|
||||||
|
break
|
||||||
return input_directory, input_name, input_category, input_hash, input_id
|
return input_directory, input_name, input_category, input_hash, input_id
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue