mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -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
|
@ -178,6 +178,11 @@ TRANSMISSION_PORT = None
|
|||
TRANSMISSION_USER = None
|
||||
TRANSMISSION_PASSWORD = None
|
||||
|
||||
SYNO_HOST = None
|
||||
SYNO_PORT = None
|
||||
SYNO_USER = None
|
||||
SYNO_PASSWORD = None
|
||||
|
||||
DELUGE_HOST = None
|
||||
DELUGE_PORT = None
|
||||
DELUGE_USER = None
|
||||
|
|
|
@ -11,7 +11,7 @@ from core.plugins.downloaders.torrent.utils import create_torrent_class
|
|||
|
||||
def configure_torrents(config):
|
||||
torrent_config = config['Torrent']
|
||||
core.TORRENT_CLIENT_AGENT = torrent_config['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other
|
||||
core.TORRENT_CLIENT_AGENT = torrent_config['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent | synods | other
|
||||
core.OUTPUT_DIRECTORY = torrent_config['outputDirectory'] # /abs/path/to/complete/
|
||||
core.TORRENT_DEFAULT_DIRECTORY = torrent_config['default_downloadDirectory']
|
||||
|
||||
|
@ -25,6 +25,7 @@ def configure_torrents(config):
|
|||
configure_transmission(torrent_config)
|
||||
configure_deluge(torrent_config)
|
||||
configure_qbittorrent(torrent_config)
|
||||
configure_syno(torrent_config)
|
||||
|
||||
|
||||
def configure_torrent_linking(config):
|
||||
|
@ -69,6 +70,13 @@ def configure_transmission(config):
|
|||
core.TRANSMISSION_PASSWORD = config['TransmissionPWD'] # mysecretpwr
|
||||
|
||||
|
||||
def configure_syno(config):
|
||||
core.SYNO_HOST = config['synoHost'] # localhost
|
||||
core.SYNO_PORT = int(config['synoPort'])
|
||||
core.SYNO_USER = config['synoUSR'] # mysecretusr
|
||||
core.SYNO_PASSWORD = config['synoPWD'] # mysecretpwr
|
||||
|
||||
|
||||
def configure_deluge(config):
|
||||
core.DELUGE_HOST = config['DelugeHost'] # localhost
|
||||
core.DELUGE_PORT = int(config['DelugePort']) # 8084
|
||||
|
|
27
core/plugins/downloaders/torrent/synology.py
Normal file
27
core/plugins/downloaders/torrent/synology.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from __future__ import (
|
||||
absolute_import,
|
||||
division,
|
||||
print_function,
|
||||
unicode_literals,
|
||||
)
|
||||
|
||||
from syno.downloadstation import DownloadStation
|
||||
|
||||
import core
|
||||
from core import logger
|
||||
|
||||
|
||||
def configure_client():
|
||||
agent = 'synology'
|
||||
host = core.SYNO_HOST
|
||||
port = core.SYNO_PORT
|
||||
user = core.SYNO_USER
|
||||
password = core.SYNO_PASSWORD
|
||||
|
||||
logger.debug('Connecting to {0}: http://{1}:{2}'.format(agent, host, port))
|
||||
try:
|
||||
client = DownloadStation(host, port, user, password)
|
||||
except Exception:
|
||||
logger.error('Failed to connect to synology')
|
||||
else:
|
||||
return client
|
|
@ -14,12 +14,14 @@ from .deluge import configure_client as deluge_client
|
|||
from .qbittorrent import configure_client as qbittorrent_client
|
||||
from .transmission import configure_client as transmission_client
|
||||
from .utorrent import configure_client as utorrent_client
|
||||
from .synology import configure_client as synology_client
|
||||
|
||||
torrent_clients = {
|
||||
'deluge': deluge_client,
|
||||
'qbittorrent': qbittorrent_client,
|
||||
'transmission': transmission_client,
|
||||
'utorrent': utorrent_client,
|
||||
'synods': synology_client,
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +41,8 @@ def pause_torrent(client_agent, input_hash, input_id, input_name):
|
|||
core.TORRENT_CLASS.stop(input_hash)
|
||||
if client_agent == 'transmission' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.stop_torrent(input_id)
|
||||
if client_agent == 'synods' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.pause_task(input_id)
|
||||
if client_agent == 'deluge' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.core.pause_torrent([input_id])
|
||||
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != '':
|
||||
|
@ -57,6 +61,8 @@ def resume_torrent(client_agent, input_hash, input_id, input_name):
|
|||
core.TORRENT_CLASS.start(input_hash)
|
||||
if client_agent == 'transmission' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.start_torrent(input_id)
|
||||
if client_agent == 'synods' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.resume_task(input_id)
|
||||
if client_agent == 'deluge' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.core.resume_torrent([input_id])
|
||||
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != '':
|
||||
|
@ -75,6 +81,8 @@ def remove_torrent(client_agent, input_hash, input_id, input_name):
|
|||
core.TORRENT_CLASS.remove(input_hash)
|
||||
if client_agent == 'transmission' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.remove_torrent(input_id, True)
|
||||
if client_agent == 'synods' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.delete_task(input_id)
|
||||
if client_agent == 'deluge' and core.TORRENT_CLASS != '':
|
||||
core.TORRENT_CLASS.core.remove_torrent(input_id, True)
|
||||
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != '':
|
||||
|
|
|
@ -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