diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-09-04 16:53:08 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-09-04 16:53:08 +0200 |
commit | fa6704b50b8b98288f344f7b9051938ef32e0325 (patch) | |
tree | 3615e591d33f93e21551ce921e464d8233e1909b /module/plugins/hooks/TransmissionRPC.py | |
parent | Spare fixes (2) (diff) | |
parent | Update TransmissionRPC.py (diff) | |
download | pyload-fa6704b50b8b98288f344f7b9051938ef32e0325.tar.xz |
Merge pull request #1807 from GammaC0de/patch-1
[TransmissionRPC] Update
Diffstat (limited to 'module/plugins/hooks/TransmissionRPC.py')
-rw-r--r-- | module/plugins/hooks/TransmissionRPC.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py index 9a9ee04b7..2ca06a9ad 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.11" + __version__ = "0.12" __status__ = "testing" __pattern__ = r"https?://.+\.torrent|magnet:\?.+" @@ -35,11 +35,11 @@ class TransmissionRPC(Addon): for url in urls: self.log_debug("Sending link: %s" % url) - self.SendToTransmission(url) + self.send_to_transmission(url) links.remove(url) - def SendToTransmission(self, url): + def send_to_transmission(self, url): transmission_rpc_url = self.get_config('rpc_url') client_request_id = self.__name__ + "".join(random.choice('0123456789ABCDEF') for _i in xrange(4)) req = get_request() @@ -56,17 +56,24 @@ class TransmissionRPC(Addon): 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]) - response = self.load(transmission_rpc_url, - post=json_dumps({'arguments': {'filename': url}, - 'method' : 'torrent-add', - 'tag' : client_request_id}), - req=req) - + 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: + self.log_error(e) + return + else: self.log_error(e) + return except Exception, e: self.log_error(e) + return try: res = json_loads(response) |