Test downloader connection: Check version of uTorrent and Sabnzbd

This commit is contained in:
mikke89
2014-02-21 02:09:16 +01:00
parent 660e20dada
commit 1f18d2b09c
3 changed files with 28 additions and 3 deletions

View File

@@ -166,7 +166,10 @@ class Downloader(Provider):
return {'success': self.testable}
def _test(self):
return {'success': self.test()}
t = self.test()
if isinstance(t,tuple):
return {'success': t[0], 'msg': t[1] }
return {'success': t }
def test(self):
return False

View File

@@ -19,13 +19,22 @@ class Sabnzbd(Downloader):
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.'
sab_data = self.call({
'mode': 'qstatus',
})
if not sab_data:
return False
except:
return False
return bool(sab_data)
return True
def download(self, data = None, media = None, filedata = None):
if not media: media = {}

View File

@@ -49,8 +49,14 @@ class uTorrent(Downloader):
return self.utorrent_api
def test(self):
if self.connect() and self.utorrent_api.get_status():
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):
@@ -329,3 +335,10 @@ class uTorrentAPI(object):
def get_files(self, hash):
action = 'action=getfiles&hash=%s' % hash
return self._request(action)
def get_build(self):
data = self._request('')
if not data:
return False
response = json.loads(data)
return int(response.get('build'))