From 2c9c4d32db09972134d65aa79121f53073006120 Mon Sep 17 00:00:00 2001 From: Noam Date: Sun, 28 Feb 2016 22:48:37 +0200 Subject: [PATCH] Another Fix For Encoding Issues - Apparently some torrents are already proper UTF8 so we don't need to encode them... --- headphones/deluge.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/headphones/deluge.py b/headphones/deluge.py index 770c7073..809298f7 100644 --- a/headphones/deluge.py +++ b/headphones/deluge.py @@ -390,8 +390,9 @@ def _add_torrent_file(result): except UnicodeDecodeError: try: # content is torrent file contents that needs to be encoded to base64 + # this time let's try leaving the encoding alone post_data = json.dumps({"method": "core.add_torrent_file", - "params": [result['name'] + '.torrent', b64encode(result['content'].decode('utf-8').encode('utf8')), {}], + "params": [result['name'] + '.torrent', b64encode(result['content']), {}], "id": 2}) response = requests.post(delugeweb_url, data=post_data.encode('utf-8'), cookies=delugeweb_auth, verify=deluge_verify_cert)