Test downloader connection: Check version of uTorrent and Sabnzbd
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user