From a4154119cba05a63895e7b427de0a2d7eafca958 Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Fri, 14 May 2021 12:01:13 -0400 Subject: [PATCH 1/2] fix Python 2 encoding issues --- addon.xml | 3 +-- changelog.txt | 3 +++ resources/lib/twitch_addon/addon/menu_items.py | 7 +++++++ resources/lib/twitch_addon/routes/edit_blacklist.py | 5 +++++ resources/lib/twitch_addon/routes/edit_qualities.py | 8 +++++++- resources/lib/twitch_addon/routes/token_url.py | 7 +++++++ 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/addon.xml b/addon.xml index 227d662a..708099af 100644 --- a/addon.xml +++ b/addon.xml @@ -13,8 +13,7 @@ all -[fix] dialogs -[lang] added Russian translation - DimmKG +[fix] Python 2 encoding issues icon.png diff --git a/changelog.txt b/changelog.txt index cdbe37bf..c357b600 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2.5.6 +[fix] Python 2 encoding issues + 2.5.5 [fix] dialogs [lang] added Russian translation - DimmKG diff --git a/resources/lib/twitch_addon/addon/menu_items.py b/resources/lib/twitch_addon/addon/menu_items.py index 7a8b38ee..40574d0d 100644 --- a/resources/lib/twitch_addon/addon/menu_items.py +++ b/resources/lib/twitch_addon/addon/menu_items.py @@ -9,6 +9,8 @@ See LICENSES/GPL-3.0-only for more information. """ +from six import PY2 + from . import utils from .common import kodi from .constants import MODES, Scripts @@ -32,6 +34,8 @@ def clear_search_history(search_type, do_refresh=False): def remove_search_history(search_type, query, do_refresh=True): + if PY2 and isinstance(query, unicode): + query = query.encode('utf-8') query_label = '[B]%s[/B]' % query params = {'mode': MODES.REMOVESEARCHHISTORY, 'search_type': search_type, 'query': query} if not do_refresh: @@ -62,6 +66,9 @@ def edit_block(target_id, display_name): def add_blacklist(target_id, display_name, list_type='user'): + if PY2 and isinstance(display_name, unicode): + display_name = display_name.encode('utf-8') + return run_plugin(i18n('add_blacklist') % ''.join(['[COLOR=white][B]', display_name, '[/B][/COLOR]']), {'mode': MODES.EDITBLACKLIST, 'target_id': target_id, 'name': display_name, 'list_type': list_type, 'refresh': True}) diff --git a/resources/lib/twitch_addon/routes/edit_blacklist.py b/resources/lib/twitch_addon/routes/edit_blacklist.py index d8215e0c..52c028ea 100644 --- a/resources/lib/twitch_addon/routes/edit_blacklist.py +++ b/resources/lib/twitch_addon/routes/edit_blacklist.py @@ -8,6 +8,9 @@ SPDX-License-Identifier: GPL-3.0-only See LICENSES/GPL-3.0-only for more information. """ + +from six import PY2 + from ..addon import utils from ..addon.common import kodi from ..addon.constants import Scripts @@ -28,6 +31,8 @@ def route(list_type='user', target_id=None, name=None, remove=False, refresh=Fal else: result = utils.remove_blacklist(list_type) if result: + if PY2 and isinstance(result[1], unicode): + result[1] = result[1].encode('utf-8') kodi.notify(msg=i18n('removed_from_blacklist') % result[1], sound=False) if refresh: diff --git a/resources/lib/twitch_addon/routes/edit_qualities.py b/resources/lib/twitch_addon/routes/edit_qualities.py index 1cde300d..5dffd761 100644 --- a/resources/lib/twitch_addon/routes/edit_qualities.py +++ b/resources/lib/twitch_addon/routes/edit_qualities.py @@ -8,6 +8,9 @@ SPDX-License-Identifier: GPL-3.0-only See LICENSES/GPL-3.0-only for more information. """ + +from six import PY2 + from ..addon import utils from ..addon.common import kodi from ..addon.constants import ADAPTIVE_SOURCE_TEMPLATE, LINE_LENGTH @@ -39,4 +42,7 @@ def route(api, content_type, target_id=None, name=None, video_id=None, remove=Fa else: result = utils.remove_default_quality(content_type) if result: - kodi.notify(msg=i18n('removed_default_quality') % (content_type, result[result.keys()[0]]['name']), sound=False) + name = result[result.keys()[0]]['name'] + if PY2 and isinstance(name, unicode): + name = name.encode('utf-8') + kodi.notify(msg=i18n('removed_default_quality') % (content_type, name), sound=False) diff --git a/resources/lib/twitch_addon/routes/token_url.py b/resources/lib/twitch_addon/routes/token_url.py index 204f0b05..10da4c27 100644 --- a/resources/lib/twitch_addon/routes/token_url.py +++ b/resources/lib/twitch_addon/routes/token_url.py @@ -8,6 +8,9 @@ SPDX-License-Identifier: GPL-3.0-only See LICENSES/GPL-3.0-only for more information. """ + +from six import PY2 + from ..addon import utils from ..addon.common import kodi from ..addon.google_firebase import dynamic_links_short_url @@ -22,6 +25,10 @@ def route(api): except: short_url = None prompt_url = short_url if short_url else i18n('authorize_url_fail') + + if PY2 and isinstance(prompt_url, unicode): + prompt_url = prompt_url.encode('utf-8') + result = kodi.Dialog().ok(i18n('authorize_heading'), i18n('authorize_message') + '[CR]%s' % prompt_url) kodi.show_settings() From 3e02ed6abbc955d44dd4fba8a4e92fbedb14bf1f Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Fri, 14 May 2021 12:02:12 -0400 Subject: [PATCH 2/2] 2.5.6 --- addon.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 708099af..ca8fd2d6 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - +