Compare commits

..
4 Commits
+14 -2
View File
@@ -85,11 +85,23 @@ def torrentAction(method, arguments):
if host.endswith('/'): if host.endswith('/'):
host = host[:-1] host = host[:-1]
# Either the host ends with a port, or some directory, or rpc
# If it ends with /rpc we don't have to do anything
# If it ends with a port we add /transmission/rpc
# anything else we just add rpc
if not host.endswith('/rpc'): if not host.endswith('/rpc'):
if host.endswith(':\d{2,6}'): # Check if it ends in a port number
i = host.rfind(':')
if i >= 0:
possible_port = host[i+1:]
try:
port = int(possible_port)
host = host + "/transmission/rpc" host = host + "/transmission/rpc"
else: except ValueError:
host = host + "/rpc" host = host + "/rpc"
else:
logger.error('Transmission port missing')
return
request = urllib2.Request(host) request = urllib2.Request(host)
if username and password: if username and password: