From 1f18d2b09c48f60399b71e808a2749ae18eb8438 Mon Sep 17 00:00:00 2001 From: mikke89 Date: Fri, 21 Feb 2014 02:09:16 +0100 Subject: [PATCH] Test downloader connection: Check version of uTorrent and Sabnzbd --- couchpotato/core/downloaders/base.py | 5 ++++- couchpotato/core/downloaders/sabnzbd/main.py | 11 ++++++++++- couchpotato/core/downloaders/utorrent/main.py | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/downloaders/base.py b/couchpotato/core/downloaders/base.py index fa274922..bb57cca7 100644 --- a/couchpotato/core/downloaders/base.py +++ b/couchpotato/core/downloaders/base.py @@ -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 diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py index 6b96d95e..b6ef7f21 100644 --- a/couchpotato/core/downloaders/sabnzbd/main.py +++ b/couchpotato/core/downloaders/sabnzbd/main.py @@ -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 = {} diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py index 6e3e4df3..d74c05cc 100644 --- a/couchpotato/core/downloaders/utorrent/main.py +++ b/couchpotato/core/downloaders/utorrent/main.py @@ -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'))