Test downloader connection: Check version of uTorrent and Sabnzbd

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

No files matched your search

+4 -1
View File
@@ -166,7 +166,10 @@ class Downloader(Provider):
return {'success': self.testable} return {'success': self.testable}
def _test(self): 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): def test(self):
return False return False
+10 -1
View File
@@ -19,13 +19,22 @@ class Sabnzbd(Downloader):
def test(self): def test(self):
try: 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({ sab_data = self.call({
'mode': 'qstatus', 'mode': 'qstatus',
}) })
if not sab_data:
return False
except: except:
return False return False
return bool(sab_data) 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 = {}
+14 -1
View File
@@ -49,8 +49,14 @@ class uTorrent(Downloader):
return self.utorrent_api return self.utorrent_api
def test(self): 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 True
return False return False
def download(self, data = None, media = None, filedata = None): def download(self, data = None, media = None, filedata = None):
@@ -329,3 +335,10 @@ class uTorrentAPI(object):
def get_files(self, hash): def get_files(self, hash):
action = 'action=getfiles&hash=%s' % hash action = 'action=getfiles&hash=%s' % hash
return self._request(action) 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'))