Cleanup downloader testbuttons PR
This commit is contained in:
@@ -15,7 +15,6 @@ class Downloader(Provider):
|
|||||||
protocol = []
|
protocol = []
|
||||||
http_time_between_calls = 0
|
http_time_between_calls = 0
|
||||||
status_support = True
|
status_support = True
|
||||||
testable = False
|
|
||||||
|
|
||||||
torrent_sources = [
|
torrent_sources = [
|
||||||
'http://torrage.com/torrent/%s.torrent',
|
'http://torrage.com/torrent/%s.torrent',
|
||||||
@@ -44,7 +43,6 @@ class Downloader(Provider):
|
|||||||
addEvent('download.remove_failed', self._removeFailed)
|
addEvent('download.remove_failed', self._removeFailed)
|
||||||
addEvent('download.pause', self._pause)
|
addEvent('download.pause', self._pause)
|
||||||
addEvent('download.process_complete', self._processComplete)
|
addEvent('download.process_complete', self._processComplete)
|
||||||
addApiView('download.%s.is_testable' % self.getName().lower(), self.isTestable)
|
|
||||||
addApiView('download.%s.test' % self.getName().lower(), self._test)
|
addApiView('download.%s.test' % self.getName().lower(), self._test)
|
||||||
|
|
||||||
def getEnabledProtocol(self):
|
def getEnabledProtocol(self):
|
||||||
@@ -162,14 +160,11 @@ class Downloader(Provider):
|
|||||||
(d_manual and manual or d_manual is False) and \
|
(d_manual and manual or d_manual is False) and \
|
||||||
(not data or self.isCorrectProtocol(data.get('protocol')))
|
(not data or self.isCorrectProtocol(data.get('protocol')))
|
||||||
|
|
||||||
def isTestable(self):
|
|
||||||
return {'success': self.testable}
|
|
||||||
|
|
||||||
def _test(self):
|
def _test(self):
|
||||||
t = self.test()
|
t = self.test()
|
||||||
if isinstance(t,tuple):
|
if isinstance(t, tuple):
|
||||||
return {'success': t[0], 'msg': t[1] }
|
return {'success': t[0], 'msg': t[1]}
|
||||||
return {'success': t }
|
return {'success': t}
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
from couchpotato.core.downloaders.base import Downloader
|
from couchpotato.core.downloaders.base import Downloader
|
||||||
|
from couchpotato.core.helpers.encoding import sp
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
import os
|
import os
|
||||||
@@ -67,6 +68,20 @@ class Blackhole(Downloader):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
directory = self.conf('directory')
|
||||||
|
if directory and os.path.isdir(directory):
|
||||||
|
|
||||||
|
test_file = sp(os.path.join(directory, 'couchpotato_test.txt'))
|
||||||
|
|
||||||
|
# Check if folder is writable
|
||||||
|
self.createFile(test_file, 'This is a test file')
|
||||||
|
if os.path.isfile(test_file):
|
||||||
|
os.remove(test_file)
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def getEnabledProtocol(self):
|
def getEnabledProtocol(self):
|
||||||
if self.conf('use_for') == 'both':
|
if self.conf('use_for') == 'both':
|
||||||
return super(Blackhole, self).getEnabledProtocol()
|
return super(Blackhole, self).getEnabledProtocol()
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Deluge(Downloader):
|
|||||||
protocol = ['torrent', 'torrent_magnet']
|
protocol = ['torrent', 'torrent_magnet']
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
drpc = None
|
drpc = None
|
||||||
testable = True
|
|
||||||
|
|
||||||
def connect(self, reconnect = False):
|
def connect(self, reconnect = False):
|
||||||
# Load host from config and split out port.
|
# Load host from config and split out port.
|
||||||
@@ -33,11 +32,6 @@ class Deluge(Downloader):
|
|||||||
|
|
||||||
return self.drpc
|
return self.drpc
|
||||||
|
|
||||||
def test(self):
|
|
||||||
if self.connect(True) and self.drpc.test():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
if not data: data = {}
|
if not data: data = {}
|
||||||
@@ -92,6 +86,11 @@ class Deluge(Downloader):
|
|||||||
log.info('Torrent sent to Deluge successfully.')
|
log.info('Torrent sent to Deluge successfully.')
|
||||||
return self.downloadReturnId(remote_torrent)
|
return self.downloadReturnId(remote_torrent)
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
if self.connect(True) and self.drpc.test():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self, ids):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking Deluge download status.')
|
log.debug('Checking Deluge download status.')
|
||||||
|
|||||||
@@ -16,30 +16,7 @@ log = CPLog(__name__)
|
|||||||
class NZBGet(Downloader):
|
class NZBGet(Downloader):
|
||||||
|
|
||||||
protocol = ['nzb']
|
protocol = ['nzb']
|
||||||
|
|
||||||
rpc = 'xmlrpc'
|
rpc = 'xmlrpc'
|
||||||
testable = True
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
url = cleanHost(host = self.conf('host'), ssl = self.conf('ssl'), username = self.conf('username'), password = self.conf('password')) + self.rpc
|
|
||||||
rpc = xmlrpclib.ServerProxy(url)
|
|
||||||
|
|
||||||
try:
|
|
||||||
if rpc.writelog('INFO', 'CouchPotato connected to test connection'):
|
|
||||||
log.debug('Successfully connected to NZBGet')
|
|
||||||
else:
|
|
||||||
log.info('Successfully connected to NZBGet, but unable to send a message')
|
|
||||||
except socket.error:
|
|
||||||
log.error('NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct.')
|
|
||||||
return False
|
|
||||||
except xmlrpclib.ProtocolError as e:
|
|
||||||
if e.errcode == 401:
|
|
||||||
log.error('Password is incorrect.')
|
|
||||||
else:
|
|
||||||
log.error('Protocol Error: %s', e)
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
@@ -53,8 +30,7 @@ class NZBGet(Downloader):
|
|||||||
|
|
||||||
nzb_name = ss('%s.nzb' % self.createNzbName(data, media))
|
nzb_name = ss('%s.nzb' % self.createNzbName(data, media))
|
||||||
|
|
||||||
url = cleanHost(host = self.conf('host'), ssl = self.conf('ssl'), username = self.conf('username'), password = self.conf('password')) + self.rpc
|
rpc = self.getRPC()
|
||||||
rpc = xmlrpclib.ServerProxy(url)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if rpc.writelog('INFO', 'CouchPotato connected to drop off %s.' % nzb_name):
|
if rpc.writelog('INFO', 'CouchPotato connected to drop off %s.' % nzb_name):
|
||||||
@@ -90,12 +66,31 @@ class NZBGet(Downloader):
|
|||||||
log.error('NZBGet could not add %s to the queue.', nzb_name)
|
log.error('NZBGet could not add %s to the queue.', nzb_name)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
rpc = self.getRPC()
|
||||||
|
|
||||||
|
try:
|
||||||
|
if rpc.writelog('INFO', 'CouchPotato connected to test connection'):
|
||||||
|
log.debug('Successfully connected to NZBGet')
|
||||||
|
else:
|
||||||
|
log.info('Successfully connected to NZBGet, but unable to send a message')
|
||||||
|
except socket.error:
|
||||||
|
log.error('NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct.')
|
||||||
|
return False
|
||||||
|
except xmlrpclib.ProtocolError as e:
|
||||||
|
if e.errcode == 401:
|
||||||
|
log.error('Password is incorrect.')
|
||||||
|
else:
|
||||||
|
log.error('Protocol Error: %s', e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def getAllDownloadStatus(self, ids):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking NZBGet download status.')
|
log.debug('Checking NZBGet download status.')
|
||||||
|
|
||||||
url = cleanHost(host = self.conf('host'), ssl = self.conf('ssl'), username = self.conf('username'), password = self.conf('password')) + self.rpc
|
rpc = self.getRPC()
|
||||||
rpc = xmlrpclib.ServerProxy(url)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if rpc.writelog('INFO', 'CouchPotato connected to check status'):
|
if rpc.writelog('INFO', 'CouchPotato connected to check status'):
|
||||||
@@ -180,8 +175,7 @@ class NZBGet(Downloader):
|
|||||||
|
|
||||||
log.info('%s failed downloading, deleting...', release_download['name'])
|
log.info('%s failed downloading, deleting...', release_download['name'])
|
||||||
|
|
||||||
url = cleanHost(host = self.conf('host'), ssl = self.conf('ssl'), username = self.conf('username'), password = self.conf('password')) + self.rpc
|
rpc = self.getRPC()
|
||||||
rpc = xmlrpclib.ServerProxy(url)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if rpc.writelog('INFO', 'CouchPotato connected to delete some history'):
|
if rpc.writelog('INFO', 'CouchPotato connected to delete some history'):
|
||||||
@@ -216,3 +210,7 @@ class NZBGet(Downloader):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def getRPC(self):
|
||||||
|
url = cleanHost(host = self.conf('host'), ssl = self.conf('ssl'), username = self.conf('username'), password = self.conf('password')) + self.rpc
|
||||||
|
return xmlrpclib.ServerProxy(url)
|
||||||
|
|||||||
@@ -24,15 +24,6 @@ class NZBVortex(Downloader):
|
|||||||
protocol = ['nzb']
|
protocol = ['nzb']
|
||||||
api_level = None
|
api_level = None
|
||||||
session_id = None
|
session_id = None
|
||||||
testable = True
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
try:
|
|
||||||
login_result = self.login()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return login_result
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
@@ -51,6 +42,14 @@ class NZBVortex(Downloader):
|
|||||||
log.error('Something went wrong sending the NZB file: %s', traceback.format_exc())
|
log.error('Something went wrong sending the NZB file: %s', traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
try:
|
||||||
|
login_result = self.login()
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return login_result
|
||||||
|
|
||||||
def getAllDownloadStatus(self, ids):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
raw_statuses = self.call('nzb')
|
raw_statuses = self.call('nzb')
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
from couchpotato.core.downloaders.base import Downloader
|
from couchpotato.core.downloaders.base import Downloader
|
||||||
|
from couchpotato.core.helpers.encoding import sp
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
@@ -56,3 +57,17 @@ class Pneumatic(Downloader):
|
|||||||
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc()))
|
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
directory = self.conf('directory')
|
||||||
|
if directory and os.path.isdir(directory):
|
||||||
|
|
||||||
|
test_file = sp(os.path.join(directory, 'couchpotato_test.txt'))
|
||||||
|
|
||||||
|
# Check if folder is writable
|
||||||
|
self.createFile(test_file, 'This is a test file')
|
||||||
|
if os.path.isfile(test_file):
|
||||||
|
os.remove(test_file)
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class rTorrent(Downloader):
|
|||||||
|
|
||||||
protocol = ['torrent', 'torrent_magnet']
|
protocol = ['torrent', 'torrent_magnet']
|
||||||
rt = None
|
rt = None
|
||||||
testable = True
|
|
||||||
error_msg = ''
|
error_msg = ''
|
||||||
|
|
||||||
# Migration url to host options
|
# Migration url to host options
|
||||||
@@ -49,7 +48,7 @@ class rTorrent(Downloader):
|
|||||||
self.rt = None
|
self.rt = None
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def connect(self):
|
def connect(self, reconnect = False):
|
||||||
# Already connected?
|
# Already connected?
|
||||||
if not reconnect and self.rt is not None:
|
if not reconnect and self.rt is not None:
|
||||||
return self.rt
|
return self.rt
|
||||||
|
|||||||
@@ -15,27 +15,6 @@ log = CPLog(__name__)
|
|||||||
class Sabnzbd(Downloader):
|
class Sabnzbd(Downloader):
|
||||||
|
|
||||||
protocol = ['nzb']
|
protocol = ['nzb']
|
||||||
testable = True
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
try:
|
|
||||||
sab_data = self.call({
|
|
||||||
'mode': 'version',
|
|
||||||
})
|
|
||||||
v = sab_data.split('.')
|
|
||||||
if int(v[0]) == 0 and int(v[1]) < 7:
|
|
||||||
return False, 'Your Sabnzbd client is too old, please update to newest version.'
|
|
||||||
|
|
||||||
# the version check will work even with wrong api key, so we need the next check as well
|
|
||||||
sab_data = self.call({
|
|
||||||
'mode': 'qstatus',
|
|
||||||
})
|
|
||||||
if not sab_data:
|
|
||||||
return False
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
@@ -85,6 +64,26 @@ class Sabnzbd(Downloader):
|
|||||||
log.error('Error getting data from SABNZBd: %s', sab_data)
|
log.error('Error getting data from SABNZBd: %s', sab_data)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
try:
|
||||||
|
sab_data = self.call({
|
||||||
|
'mode': 'version',
|
||||||
|
})
|
||||||
|
v = sab_data.split('.')
|
||||||
|
if int(v[0]) == 0 and int(v[1]) < 7:
|
||||||
|
return False, 'Your Sabnzbd client is too old, please update to newest version.'
|
||||||
|
|
||||||
|
# the version check will work even with wrong api key, so we need the next check as well
|
||||||
|
sab_data = self.call({
|
||||||
|
'mode': 'qstatus',
|
||||||
|
})
|
||||||
|
if not sab_data:
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def getAllDownloadStatus(self, ids):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking SABnzbd download status.')
|
log.debug('Checking SABnzbd download status.')
|
||||||
|
|||||||
@@ -13,17 +13,6 @@ class Synology(Downloader):
|
|||||||
|
|
||||||
protocol = ['nzb', 'torrent', 'torrent_magnet']
|
protocol = ['nzb', 'torrent', 'torrent_magnet']
|
||||||
status_support = False
|
status_support = False
|
||||||
testable = True
|
|
||||||
|
|
||||||
def test(self):
|
|
||||||
host = cleanHost(self.conf('host'), protocol = False).split(':')
|
|
||||||
try:
|
|
||||||
srpc = SynologyRPC(host[0], host[1], self.conf('username'), self.conf('password'))
|
|
||||||
test_result = srpc.test()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return test_result
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
@@ -56,6 +45,16 @@ class Synology(Downloader):
|
|||||||
finally:
|
finally:
|
||||||
return self.downloadReturnId('') if response else False
|
return self.downloadReturnId('') if response else False
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
host = cleanHost(self.conf('host'), protocol = False).split(':')
|
||||||
|
try:
|
||||||
|
srpc = SynologyRPC(host[0], host[1], self.conf('username'), self.conf('password'))
|
||||||
|
test_result = srpc.test()
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return test_result
|
||||||
|
|
||||||
def getEnabledProtocol(self):
|
def getEnabledProtocol(self):
|
||||||
if self.conf('use_for') == 'both':
|
if self.conf('use_for') == 'both':
|
||||||
return super(Synology, self).getEnabledProtocol()
|
return super(Synology, self).getEnabledProtocol()
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class Transmission(Downloader):
|
|||||||
protocol = ['torrent', 'torrent_magnet']
|
protocol = ['torrent', 'torrent_magnet']
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
trpc = None
|
trpc = None
|
||||||
testable = True
|
|
||||||
|
|
||||||
def connect(self, reconnect = False):
|
def connect(self, reconnect = False):
|
||||||
# Load host from config and split out port.
|
# Load host from config and split out port.
|
||||||
@@ -32,11 +31,6 @@ class Transmission(Downloader):
|
|||||||
|
|
||||||
return self.trpc
|
return self.trpc
|
||||||
|
|
||||||
def test(self):
|
|
||||||
if self.connect(True) and self.trpc.get_session():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
if not data: data = {}
|
if not data: data = {}
|
||||||
@@ -89,6 +83,11 @@ class Transmission(Downloader):
|
|||||||
log.info('Torrent sent to Transmission successfully.')
|
log.info('Torrent sent to Transmission successfully.')
|
||||||
return self.downloadReturnId(remote_torrent['torrent-added']['hashString'])
|
return self.downloadReturnId(remote_torrent['torrent-added']['hashString'])
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
if self.connect(True) and self.trpc.get_session():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self, ids):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking Transmission download status.')
|
log.debug('Checking Transmission download status.')
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from base64 import b16encode, b32decode
|
from base64 import b16encode, b32decode
|
||||||
from bencode import bencode as benc, bdecode
|
from bencode import bencode as benc, bdecode
|
||||||
from couchpotato.api import addApiView
|
|
||||||
from couchpotato.core.downloaders.base import Downloader, ReleaseDownloadList
|
from couchpotato.core.downloaders.base import Downloader, ReleaseDownloadList
|
||||||
from couchpotato.core.helpers.encoding import isInt, ss, sp
|
from couchpotato.core.helpers.encoding import isInt, ss, sp
|
||||||
from couchpotato.core.helpers.variable import tryInt, tryFloat, cleanHost
|
from couchpotato.core.helpers.variable import tryInt, tryFloat, cleanHost
|
||||||
@@ -25,7 +24,6 @@ class uTorrent(Downloader):
|
|||||||
|
|
||||||
protocol = ['torrent', 'torrent_magnet']
|
protocol = ['torrent', 'torrent_magnet']
|
||||||
utorrent_api = None
|
utorrent_api = None
|
||||||
testable = True
|
|
||||||
status_flags = {
|
status_flags = {
|
||||||
'STARTED' : 1,
|
'STARTED' : 1,
|
||||||
'CHECKING' : 2,
|
'CHECKING' : 2,
|
||||||
@@ -48,17 +46,6 @@ class uTorrent(Downloader):
|
|||||||
|
|
||||||
return self.utorrent_api
|
return self.utorrent_api
|
||||||
|
|
||||||
def test(self):
|
|
||||||
if self.connect():
|
|
||||||
build_version = self.utorrent_api.get_build()
|
|
||||||
if not build_version:
|
|
||||||
return False
|
|
||||||
if build_version < 25406: # This build corresponds to version 3.0.0 stable
|
|
||||||
return False, 'Your uTorrent client is too old, please update to newest version.'
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
if not data: data = {}
|
if not data: data = {}
|
||||||
@@ -128,6 +115,17 @@ class uTorrent(Downloader):
|
|||||||
|
|
||||||
return self.downloadReturnId(torrent_hash)
|
return self.downloadReturnId(torrent_hash)
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
if self.connect():
|
||||||
|
build_version = self.utorrent_api.get_build()
|
||||||
|
if not build_version:
|
||||||
|
return False
|
||||||
|
if build_version < 25406: # This build corresponds to version 3.0.0 stable
|
||||||
|
return False, 'Your uTorrent client is too old, please update to newest version.'
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self, ids):
|
def getAllDownloadStatus(self, ids):
|
||||||
|
|
||||||
log.debug('Checking uTorrent download status.')
|
log.debug('Checking uTorrent download status.')
|
||||||
|
|||||||
@@ -27,48 +27,41 @@ var DownloadersBase = new Class({
|
|||||||
|
|
||||||
if(button_name.contains('Downloaders')) return;
|
if(button_name.contains('Downloaders')) return;
|
||||||
|
|
||||||
Api.request('download.'+plugin_name+'.is_testable', {
|
new Element('.ctrlHolder.test_button').adopt(
|
||||||
'onComplete': function(json){
|
new Element('a.button', {
|
||||||
if(json.success){
|
'text': button_name,
|
||||||
// Only add test button if downloader is testable
|
'events': {
|
||||||
new Element('.ctrlHolder.test_button').adopt(
|
'click': function(){
|
||||||
new Element('a.button', {
|
var button = fieldset.getElement('.test_button .button');
|
||||||
'text': button_name,
|
button.set('text', 'Connecting...');
|
||||||
'events': {
|
|
||||||
'click': function(){
|
|
||||||
var button = fieldset.getElement('.test_button .button');
|
|
||||||
button.set('text', 'Connecting...');
|
|
||||||
|
|
||||||
Api.request('download.'+plugin_name+'.test', {
|
Api.request('download.'+plugin_name+'.test', {
|
||||||
'onComplete': function(json){
|
'onComplete': function(json){
|
||||||
|
|
||||||
button.set('text', button_name);
|
button.set('text', button_name);
|
||||||
|
|
||||||
if(json.success){
|
if(json.success){
|
||||||
var message = new Element('span.success', {
|
var message = new Element('span.success', {
|
||||||
'text': 'Connection successful'
|
'text': 'Connection successful'
|
||||||
}).inject(button, 'after')
|
}).inject(button, 'after')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var msg_text = 'Connection failed. Check logs for details.';
|
var msg_text = 'Connection failed. Check logs for details.';
|
||||||
if(json.hasOwnProperty('msg')) msg_text = json.msg;
|
if(json.hasOwnProperty('msg')) msg_text = json.msg;
|
||||||
var message = new Element('span.failed', {
|
var message = new Element('span.failed', {
|
||||||
'text': msg_text
|
'text': msg_text
|
||||||
}).inject(button, 'after')
|
}).inject(button, 'after')
|
||||||
}
|
}
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
message.destroy();
|
message.destroy();
|
||||||
}).delay(3000)
|
}).delay(3000)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
).inject(fieldset);
|
).inject(fieldset);
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -79,4 +72,4 @@ var DownloadersBase = new Class({
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.Downloaders = new DownloadersBase();
|
window.Downloaders = new DownloadersBase();
|
||||||
|
|||||||
Reference in New Issue
Block a user