Convert some strings to unicode to avoid encoding errors

This commit is contained in:
Thomas Bétous 2021-05-10 23:46:15 +02:00
parent f21795a99a
commit 7aeb534500
2 changed files with 13 additions and 5 deletions

View File

@ -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
)

View File

@ -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