From 30bc8e4d069e41110da45f9c3ed0054270d320ab Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Wed, 13 Jan 2016 15:49:39 +0300 Subject: [PATCH] qbit fixes --- .idea/workspace.xml | 1401 ++++++++++++++++++++----------------- Core.py | 2 +- functions.py | 6 + resources/utorrent/net.py | 34 +- 4 files changed, 796 insertions(+), 647 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a7fd080..5bcc57b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,9 @@ - + + + @@ -37,7 +39,7 @@ - + @@ -167,82 +169,124 @@ - - + + - + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -265,10 +309,10 @@ - + - + @@ -297,75 +341,51 @@ - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -374,17 +394,21 @@ - - + + + + + + - + - - + + @@ -412,25 +436,12 @@ @@ -530,104 +554,6 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1115,15 +1153,15 @@ + - - + + - @@ -1147,9 +1185,6 @@ - - - @@ -1172,313 +1207,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1500,44 +1240,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1559,13 +1261,6 @@ - - - - - - - @@ -1713,14 +1408,6 @@ - - - - - - - - @@ -1728,40 +1415,110 @@ - + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + + + + + + + + + + + + + + + + + + + + + - - + + - + + + + + + + + + @@ -1784,5 +1541,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Core.py b/Core.py index 3607541..682bbdf 100644 --- a/Core.py +++ b/Core.py @@ -1258,7 +1258,7 @@ class Core: if not hash: actions = [('start', self.localize('Start')), ('stop', self.localize('Stop')), ('remove', self.localize('Remove')), - ('3', self.localize('High Priority All Files')), ('0', self.localize('Skip All Files')), + ('3', self.localize('High Priority Files')), ('0', self.localize('Skip All Files')), ('removedata', self.localize('Remove with files'))] folder = True diff --git a/functions.py b/functions.py index e3c79f0..a9e4c3e 100644 --- a/functions.py +++ b/functions.py @@ -1988,3 +1988,9 @@ def file_url(torrentFile): torrentFile = urlparse.urljoin('file:', urllib.pathname2url(ensure_str(torrentFile))) return torrentFile +def dump(obj): + for attr in dir(obj): + try: + log("'%s':'%s'," % (attr, getattr(obj, attr))) + except: + pass \ No newline at end of file diff --git a/resources/utorrent/net.py b/resources/utorrent/net.py index ba7bc9a..ecef3f3 100644 --- a/resources/utorrent/net.py +++ b/resources/utorrent/net.py @@ -13,7 +13,7 @@ import json import itertools from StringIO import StringIO import gzip -from functions import log +from functions import log, dump import xbmc import xbmcgui @@ -850,6 +850,7 @@ class qBittorrent: self.url += url self.http = HTTP() + self.cookie = self.get_auth() def list(self): obj = self.action('/query/torrents') @@ -874,7 +875,8 @@ class qBittorrent: 'leech': r['num_leechs'], 'dir': r['save_path'] } - #if len(r['files']) > 1: add['dir'] = os.path.join(r['save_path'], r['name']) + flist = self.action('/query/propertiesFiles/'+r['hash']) + if len(flist) > 1: add['dir'] = os.path.join(r['save_path'], r['name']) res.append(add) return res @@ -981,7 +983,7 @@ class qBittorrent: return True if res else None def setprio_simple(self, id, prio, ind): - log(str((id, prio, ind))) + #log(str((id, prio, ind))) if prio == '3': prio = '7' params = {'hash':id, 'priority':prio, 'id': ind} obj = self.action_post('/command/setFilePrio', params) @@ -995,11 +997,7 @@ class qBittorrent: self.setprio_simple(hash, action, ind) def action(self, uri, upload=None): - cookie = self.get_auth() - if not cookie: - return None - - req = HTTPRequest(self.url + uri, headers={'Cookie': cookie}) + req = HTTPRequest(self.url + uri, headers={'Cookie': self.cookie}) if upload: req.upload = upload @@ -1021,12 +1019,10 @@ class qBittorrent: return obj def action_post(self, uri, params=None): - cookie = self.get_auth() - if not cookie: - return None - - response = self.http.fetch(self.url + uri, headers={'Cookie': cookie}, method='POST', params=params, gzip=True) + response = self.http.fetch(self.url + uri, headers={'Cookie': self.cookie}, + method='POST', params=params, gzip=True,) + #dump(response) if response.error: return None @@ -1036,11 +1032,11 @@ class qBittorrent: return response def action_simple(self, action, id): - actions = {'start': '/command/resume', - 'stop': '/command/pause', - 'remove': '/command/delete', - 'removedata': '/command/deletePerm'} - obj = self.action_post(actions[action], {'hash':id}) + actions = {'start': ['/command/resume',{'hash':id,}], + 'stop': ['/command/pause',{'hash':id,}], + 'remove': ['/command/delete',{'hashes':id}], + 'removedata': ['/command/deletePerm',{'hashes':id}]} + obj = self.action_post(actions[action][0],actions[action][1]) return True if obj else None def get_auth(self): @@ -1080,7 +1076,7 @@ class Deluge: if port: self.url += ':' + str(port) self.url += url - log(str(self.url)) + #log(str(self.url)) self.http = HTTP() def get_info(self):