From 80e9831c035af7745344e73ee1de6f0e50e15e3a Mon Sep 17 00:00:00 2001 From: mano3m Date: Fri, 18 Oct 2013 00:47:08 +0200 Subject: [PATCH] Make uTorrent language independent Fixes #2341 --- couchpotato/core/downloaders/utorrent/main.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py index 6903c72..b0b9c89 100644 --- a/couchpotato/core/downloaders/utorrent/main.py +++ b/couchpotato/core/downloaders/utorrent/main.py @@ -138,19 +138,32 @@ class uTorrent(Downloader): except: log.debug('Failed getting files from torrent: %s', torrent[2]) - # torrent[21] = Paused | Downloading | Seeding | Finished + status_flags = { + "STARTED" : 1, + "CHECKING" : 2, + "CHECK-START" : 4, + "CHECKED" : 8, + "ERROR" : 16, + "PAUSED" : 32, + "QUEUED" : 64, + "LOADED" : 128 + } + status = 'busy' - if 'Finished' in torrent[21]: - status = 'completed' - self.removeReadOnly(torrent_files) - elif 'Seeding' in torrent[21]: + if (torrent[1] & status_flags["STARTED"] or torrent[1] & status_flags["QUEUED"]) and torrent[4] == 1000: status = 'seeding' + elif (torrent[1] & status_flags["ERROR"]): + status = 'failed' + elif torrent[4] == 1000: + status = 'completed' + + if not status == 'busy': self.removeReadOnly(torrent_files) release_downloads.append({ 'id': torrent[0], 'name': torrent[2], - 'status': status, + 'status': status, 'seed_ratio': float(torrent[7]) / 1000, 'original_status': torrent[1], 'timeleft': str(timedelta(seconds = torrent[10])),