From 0895100d5aeb68868d4a066139d6baa2efdaac62 Mon Sep 17 00:00:00 2001 From: Fernando Date: Fri, 6 May 2016 13:40:01 -0300 Subject: [PATCH] Fix deluge sending ratio -1 when it shouldn't send anything --- sickbeard/clients/deluge_client.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sickbeard/clients/deluge_client.py b/sickbeard/clients/deluge_client.py index ec5d3e0b96..38e3db6dfb 100644 --- a/sickbeard/clients/deluge_client.py +++ b/sickbeard/clients/deluge_client.py @@ -167,12 +167,17 @@ def _set_torrent_ratio(self, result): if result.ratio: ratio = result.ratio - if ratio: + # blank is default client ratio, so we also shouldn't set ratio + if ratio and float(ratio) >= 0: post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio", "params": [result.hash, True], "id": 5}) self._request(method='post', data=post_data) + + # Return false if we couldn't enable setting set_torrent_stop_at_ratio. No reason to set ratio. + if self.response.json()['error']: + return False post_data = json.dumps({"method": "core.set_torrent_stop_ratio", "params": [result.hash, float(ratio)], @@ -182,6 +187,17 @@ def _set_torrent_ratio(self, result): return not self.response.json()['error'] + elif ratio and float(ratio) == -1: + # Disable stop at ratio to seed forever + post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio", + "params": [result.hash, False], + "id": 5}) + + self._request(method='post', data=post_data) + + return not self.response.json()['error'] + + return True def _set_torrent_path(self, result):