From 4c3b60be68fa4b1732f7553bdf959cbe94cdc8fc Mon Sep 17 00:00:00 2001 From: Noam Date: Sun, 17 Sep 2017 01:40:04 +0300 Subject: [PATCH] UnicodeDecodeError printing torrent name containing unicode --- headphones/deluge.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/headphones/deluge.py b/headphones/deluge.py index e17a6995..99bd1382 100644 --- a/headphones/deluge.py +++ b/headphones/deluge.py @@ -170,7 +170,10 @@ def addTorrent(link, data=None, name=None): # remove '.torrent' suffix if name[-len('.torrent'):] == '.torrent': name = name[:-len('.torrent')] - logger.debug('Deluge: Sending Deluge torrent with name %s and content [%s...]' % (name, str(torrentfile)[:40])) + try: + logger.debug('Deluge: Sending Deluge torrent with name %s and content [%s...]' % (name, str(torrentfile)[:40])) + except UnicodeDecodeError: + logger.debug('Deluge: Sending Deluge torrent with name %s and content [%s...]' % (name.decode('utf-8'), str(torrentfile)[:40])) result = {'type': 'torrent', 'name': name, 'content': torrentfile}