From 68c551c8285942348341f69c640eafd029a63a82 Mon Sep 17 00:00:00 2001 From: Noam Date: Sun, 17 Sep 2017 02:40:09 +0300 Subject: [PATCH] Try DEcoding torrent name utf-8 in params --- headphones/deluge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/deluge.py b/headphones/deluge.py index 07699b0b..5eb27849 100644 --- a/headphones/deluge.py +++ b/headphones/deluge.py @@ -471,7 +471,7 @@ def _add_torrent_file(result): try: # content is torrent file contents that needs to be encoded to base64 post_data = json.dumps({"method": "core.add_torrent_file", - "params": [result['name'].encode('utf8') + '.torrent', + "params": [result['name'] + '.torrent', b64encode(result['content'].encode('utf8')), {}], "id": 2}) response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth, @@ -485,7 +485,7 @@ def _add_torrent_file(result): # this time let's try leaving the encoding as is logger.debug('Deluge: There was a decoding issue, let\'s try again') post_data = json.dumps({"method": "core.add_torrent_file", - "params": [result['name'] + '.torrent', + "params": [result['name'].decode('utf8') + '.torrent', b64encode(result['content']), {}], "id": 22}) response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth,