mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2025-01-06 19:08:53 +00:00
Patched transmissionrpc 0.8 to work with python 2.4
This commit is contained in:
parent
4b8a270714
commit
7e91d7c582
3 changed files with 57 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
# Copyright (c) 2008-2011 Erik Svensson <erik.public@gmail.com>
|
||||
# Licensed under the MIT license.
|
||||
|
||||
import sys
|
||||
import re, time
|
||||
import urllib2, urlparse, base64
|
||||
|
||||
|
@ -40,6 +41,55 @@ def debug_httperror(error):
|
|||
)
|
||||
)
|
||||
|
||||
if sys.version_info[:2] < (2, 5):
|
||||
"""
|
||||
Mimic python 2.5+ urlparse.urlparse
|
||||
"""
|
||||
_old_urlparse = urlparse.urlparse
|
||||
def _urlparse(address):
|
||||
class ParsedResult(tuple):
|
||||
def __init__(self, address = None):
|
||||
self.scheme = ''
|
||||
self.netloc = ''
|
||||
self.path = ''
|
||||
self.params = ''
|
||||
self.query = ''
|
||||
self.fragment = ''
|
||||
self.username = None
|
||||
self.password = None
|
||||
self.hostname = None
|
||||
self.port = None
|
||||
|
||||
if address:
|
||||
self.parse(address)
|
||||
def parse(self, address):
|
||||
(
|
||||
self.scheme,
|
||||
self.netloc,
|
||||
self.path,
|
||||
self.params,
|
||||
self.query,
|
||||
self.fragment
|
||||
) = _old_urlparse(address)
|
||||
self.hostname = self.netloc
|
||||
if '@' in self.netloc:
|
||||
(login, self.hostname) = self.netloc.split('@')
|
||||
if ':' in login:
|
||||
(self.username, self.password) = login.split(':')
|
||||
else:
|
||||
self.username = login
|
||||
if ':' in self.hostname:
|
||||
(self.hostname, self.port) = self.hostname.split(':')
|
||||
try:
|
||||
self.port = int(self.port)
|
||||
except:
|
||||
self.port = None
|
||||
|
||||
result = ParsedResult(address)
|
||||
return result
|
||||
|
||||
urlparse.urlparse = _urlparse
|
||||
|
||||
"""
|
||||
Torrent ids
|
||||
|
||||
|
|
|
@ -128,7 +128,9 @@ class Torrent(object):
|
|||
priorities = self.fields['priorities']
|
||||
wanted = self.fields['wanted']
|
||||
for item in zip(indices, files, priorities, wanted):
|
||||
selected = True if item[3] else False
|
||||
selected = False
|
||||
if item[3]:
|
||||
selected = True
|
||||
priority = PRIORITY[item[2]]
|
||||
result[item[0]] = {
|
||||
'selected': selected,
|
||||
|
|
|
@ -91,7 +91,10 @@ def rpc_bool(arg):
|
|||
arg = bool(int(arg))
|
||||
except ValueError:
|
||||
arg = arg.lower() in [u'true', u'yes']
|
||||
return 1 if bool(arg) else 0
|
||||
if bool(arg):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
TR_TYPE_MAP = {
|
||||
'number' : int,
|
||||
|
|
Loading…
Reference in a new issue