mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
Syno ds patch 1 (#1702)
* Add Syno DS parsing #1671 as per https://forum.synology.com/enu/viewtopic.php?f=38&t=92856 * add config guidance * add syno client
This commit is contained in:
parent
0827c5bafe
commit
b793ce7933
9 changed files with 487 additions and 2 deletions
|
@ -8,6 +8,7 @@ from __future__ import (
|
|||
import os
|
||||
|
||||
import core
|
||||
from core import logger
|
||||
|
||||
|
||||
def parse_other(args):
|
||||
|
@ -81,6 +82,36 @@ def parse_transmission(args):
|
|||
return input_directory, input_name, input_category, input_hash, input_id
|
||||
|
||||
|
||||
def parse_synods(args):
|
||||
# Synology/Transmission usage: call TorrenToMedia.py (%TR_TORRENT_DIR% %TR_TORRENT_NAME% is passed on as environmental variables)
|
||||
input_directory = ''
|
||||
input_id = ''
|
||||
input_category = ''
|
||||
input_name = os.getenv('TR_TORRENT_NAME')
|
||||
input_hash = os.getenv('TR_TORRENT_HASH')
|
||||
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))
|
||||
if res['success']:
|
||||
try:
|
||||
tasks = res['data']['tasks']
|
||||
task = [ task for task in tasks if task['id'] == input_id ][0]
|
||||
input_id = task['id']
|
||||
input_directory = task['additional']['detail']['destination']
|
||||
except:
|
||||
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/
|
||||
if not os.path.isdir(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
|
||||
|
||||
|
||||
def parse_vuze(args):
|
||||
# vuze usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py '%D%N%L%I%K%F'
|
||||
try:
|
||||
|
@ -159,6 +190,7 @@ def parse_args(client_agent, args):
|
|||
'transmission': parse_transmission,
|
||||
'qbittorrent': parse_qbittorrent,
|
||||
'vuze': parse_vuze,
|
||||
'synods': parse_synods,
|
||||
}
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue