diff options
author | GammaC0de <GammaC0de@users.noreply.github.com> | 2015-10-19 09:57:56 +0200 |
---|---|---|
committer | GammaC0de <GammaC0de@users.noreply.github.com> | 2015-10-19 09:57:56 +0200 |
commit | 72894135995cab005459c319d4dcc6e0ff23c2ec (patch) | |
tree | 288f2e15017278c0c7327080cfb9e9f7495b15f9 /module/plugins/hooks | |
parent | Fix https://github.com/pyload/pyload/issues/2056 (diff) | |
download | pyload-72894135995cab005459c319d4dcc6e0ff23c2ec.tar.xz |
Update TransmissionRPC.py
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r-- | module/plugins/hooks/TransmissionRPC.py | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py index 7d166ef20..da4ea1fc5 100644 --- a/module/plugins/hooks/TransmissionRPC.py +++ b/module/plugins/hooks/TransmissionRPC.py @@ -14,7 +14,7 @@ from module.plugins.internal.Addon import Addon class TransmissionRPC(Addon): __name__ = "TransmissionRPC" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" __status__ = "testing" __pattern__ = r"https?://.+\.torrent|magnet:\?.+" @@ -53,28 +53,23 @@ class TransmissionRPC(Addon): req=req) except Exception, e: - self.log_error(e) - return - - if req.code == 409: - headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header)) - session_id = headers['X-Transmission-Session-Id'] - req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id]) - try: - response = self.load(transmission_rpc_url, - post=json.dumps({'arguments': {'filename': url}, - 'method' : 'torrent-add', - 'tag' : client_request_id}), - req=req) - - except Exception, e: + if req.code == 409: + headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header)) + session_id = headers['X-Transmission-Session-Id'] + req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id]) + try: + response = self.load(transmission_rpc_url, + post=json.dumps({'arguments': {'filename': url}, + 'method' : 'torrent-add', + 'tag' : client_request_id}), + req=req) + + res = json.loads(response) + if "result" in res: + self.log_debug("Result: %s" % res['result']) + + except Exception, e: + self.log_error(e) + + else: self.log_error(e) - return - - try: - res = json.loads(response) - if "result" in res: - self.log_debug("Result: %s" % res['result']) - - except Exception, e: - self.log_error(e) |