diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html old mode 100755 new mode 100644 index 54ab4121..0722a42e --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -502,8 +502,8 @@ - Torrents
+ Torrents
@@ -654,27 +654,30 @@ Folder path where torrent download will be assigned
-
+
- - (ie. 192.168.1.2:58846) port uses the deluge daemon port (remote connection to daemon has to be enabled) + + (ie. 192.168.1.2:58846) port uses the deluge daemon port (remote connection to daemon has to be enabled)
- +
- +

Label to be used on the torrents
+
+ +
+
-
@@ -716,8 +719,9 @@
-
- + + + @@ -2226,6 +2230,32 @@ $('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut(); }); + $('#deluge_test').click(function () { + var imagechk = document.getElementById("deluge_status_icon"); + var host = document.getElementById("deluge_host").value; + var username = document.getElementById("deluge_username").value; + var password = document.getElementById("deluge_password").value; + $.get("testdeluge", + { host: host, username: username, password: password }, + function(data){ + if (data.error != undefined) { + alert(data.error); + return; + } + $('#ajaxMsg').html("
"+data+"
"); + if ( data.indexOf("Successfully") > -1){ + imagechk.src = ""; + imagechk.src = "interfaces/default/images/success.png"; + imagechk.style.visibility = "visible"; + } else { + imagechk.src = ""; + imagechk.src = "interfaces/default/images/fail.png"; + imagechk.style.visibility = "visible"; + } + }); + $('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut(); + }); + $(".newznabtest").click(function () { var newznab = this.attributes["name"].value.replace('newznab_test', ''); if ( newznab.indexOf("test_dognzb") > -1) { diff --git a/mylar/rsscheck.py b/mylar/rsscheck.py index c28a686f..12c64aad 100755 --- a/mylar/rsscheck.py +++ b/mylar/rsscheck.py @@ -1102,7 +1102,7 @@ def torsend2client(seriesname, issue, seriesyear, linkit, site, pubhash=None): scraper = cfscrape.create_scraper() if site == 'WWT': if mylar.WWT_CF_COOKIEVALUE is None: - cf_cookievalue, cf_user_agent = scraper.get_tokens(newurl, user_agent=mylar.CV_HEADERS['User-Agent']) + cf_cookievalue, cf_user_agent = scraper.get_tokens(url, user_agent=mylar.CV_HEADERS['User-Agent']) mylar.WWT_CF_COOKIEVALUE = cf_cookievalue r = scraper.get(url, params=payload, cookies=mylar.WWT_CF_COOKIEVALUE, verify=verify, stream=True, headers=headers) else: diff --git a/mylar/torrent/clients/deluge.py b/mylar/torrent/clients/deluge.py index d09ee3df..15451b85 100644 --- a/mylar/torrent/clients/deluge.py +++ b/mylar/torrent/clients/deluge.py @@ -8,33 +8,43 @@ from deluge_client import DelugeRPCClient class TorrentClient(object): def __init__(self): self.conn = None - - def connect(self, host, username, password): + + def connect(self, host, username, password, test=False): if self.conn is not None: return self.connect - + if not host: - return False + return {'status': False, 'error': 'No host specified'} + + if not username: + return {'status': False, 'error': 'No username specified'} + + if not password: + return {'status': False, 'error': 'No password specified'} # Get port from the config host,portnr = host.split(':') - - #if username and password: # logger.info('Connecting to ' + host + ':' + portnr + ' Username: ' + username + ' Password: ' + password ) try: self.client = DelugeRPCClient(host,int(portnr),username,password) except Exception as e: - logger.error('Could not create DelugeRPCClient Object' + e) - return False + logger.error('Could not create DelugeRPCClient Object %s' % e) + return {'status': False, 'error': e} else: try: self.client.connect() except Exception as e: - logger.error('Could not connect to Deluge ' + host) + logger.error('Could not connect to Deluge: %s' % host) + return {'status': False, 'error': e} else: - return self.client - + if test is True: + daemon_version = self.client.call('daemon.info') + libtorrent_version = self.client.call('core.get_libtorrent_version') + return {'status': True, 'daemon_version': daemon_version, 'libtorrent_version': libtorrent_version} + else: + return self.client + def find_torrent(self, hash): logger.debug('Finding Torrent hash: ' + hash) torrent_info = self.get_torrent(hash) @@ -85,16 +95,16 @@ class TorrentClient(object): else: logger.info('Torrent ' + hash + ' was stopped') return True - + def load_torrent(self, filepath): - + logger.info('filepath to torrent file set to : ' + filepath) torrent_id = False - + if self.client.connected is True: logger.info('Checking if Torrent Exists!') - + if not filepath.startswith('magnet'): torrentcontent = open(filepath, 'rb').read() hash = str.lower(self.get_the_hash(filepath)) # Deluge expects a lower case hash diff --git a/mylar/webserve.py b/mylar/webserve.py index eb94ddfd..7654458d 100644 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -5959,13 +5959,29 @@ class WebInterface(object): return 'Error establishing connection to Qbittorrent' else: if qclient['status'] is False: - logger.warn('[qBittorrent] Could not establish connection to %s. Error returned:' % (host, qclient['error'])) + logger.warn('[qBittorrent] Could not establish connection to %s. Error returned: %s' % (host, qclient['error'])) return 'Error establishing connection to Qbittorrent' else: - logger.info('[qBittorrent] Successfully validated connection to %s [%s]' % (host, qclient['version'])) + logger.info('[qBittorrent] Successfully validated connection to %s [v%s]' % (host, qclient['version'])) return 'Successfully validated qBittorrent connection' testqbit.exposed = True + def testdeluge(self, host, username, password): + import torrent.clients.deluge as DelugeClient + client = DelugeClient.TorrentClient() + dclient = client.connect(host, username, password, True) + if not dclient: + logger.warn('[Deluge] Could not establish connection to %s' % host) + return 'Error establishing connection to Deluge' + else: + if dclient['status'] is False: + logger.warn('[Deluge] Could not establish connection to %s. Error returned: %s' % (host, dclient['error'])) + return 'Error establishing connection to Deluge' + else: + logger.info('[Deluge] Successfully validated connection to %s [daemon v%s; libtorrent v%s]' % (host, dclient['daemon_version'], dclient['libtorrent_version'])) + return 'Successfully validated Deluge connection' + testdeluge.exposed = True + def testnewznab(self, name, host, ssl, apikey): logger.fdebug('ssl/verify: %s' % ssl) if 'ssl' == '0' or ssl == '1':