From 7aeb534500caa30e82e79a453060571a4411ae4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=A9tous?= Date: Mon, 10 May 2021 23:46:15 +0200 Subject: [PATCH] Convert some strings to unicode to avoid encoding errors --- resources/lib/addon.py | 6 +++--- resources/lib/kodi_utils.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/resources/lib/addon.py b/resources/lib/addon.py index 0ff5a13..bfca624 100644 --- a/resources/lib/addon.py +++ b/resources/lib/addon.py @@ -199,9 +199,9 @@ class PeerTubeAddon(): total_pages = (total / self.items_per_page) + 1 next_page_item = kodi.generate_item_info( - name="{} ({}/{})".format(kodi.get_string(30405), - next_page, - total_pages), + name=u"{} ({}/{})".format(kodi.get_string(30405), + next_page, + total_pages), url=url ) diff --git a/resources/lib/kodi_utils.py b/resources/lib/kodi_utils.py index 512bdcb..5b682c4 100644 --- a/resources/lib/kodi_utils.py +++ b/resources/lib/kodi_utils.py @@ -219,8 +219,16 @@ class KodiUtils: :return: Entered data or an empty string :rtype: str """ - return xbmcgui.Dialog().input(heading=title, - type=xbmcgui.INPUT_ALPHANUM) + entered_string = xbmcgui.Dialog().input(heading=title, + type=xbmcgui.INPUT_ALPHANUM) + + # Let's check the type of "string" against the type "bytes" to confirm + # if it is a unicode or a byte string ("bytes" is known in both + # python 2 and 3) + if isinstance(entered_string, bytes): + return entered_string.decode("utf-8") + else: + return entered_string def play(self, url): """Play the media behind the URL