From 91ed781acbdaf2abf573aea7ca874098bdf9366c Mon Sep 17 00:00:00 2001 From: Noam Date: Mon, 13 Mar 2017 22:10:57 +0200 Subject: [PATCH] More exception handling for torrent removal --- headphones/deluge.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/headphones/deluge.py b/headphones/deluge.py index 062789c6..78647b0c 100644 --- a/headphones/deluge.py +++ b/headphones/deluge.py @@ -261,7 +261,11 @@ def removeTorrent(torrentid, remove_data=False): response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth, verify=deluge_verify_cert, headers=headers) - state = json.loads(response.text)['result']['state'] + try: + state = json.loads(response.text)['result']['state'] + except KeyError as e: + logger.debug('Deluge: "state" KeyError when trying to remove torrent %s' % str(torrentid)) + return False not_finished = ["queued", "seeding", "downloading", "checking", "error"] result = False