From d306f36869389eafb7e634e62ad4345ea492c797 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 19 Dec 2020 08:19:24 +0100 Subject: [PATCH] More string bytes fixes --- resources/lib/context.py | 4 ++-- resources/lib/plexbmchelper/plexgdm.py | 1 + resources/lib/utils.py | 26 +++++--------------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/resources/lib/context.py b/resources/lib/context.py index 863c7f97..78344029 100644 --- a/resources/lib/context.py +++ b/resources/lib/context.py @@ -59,14 +59,14 @@ class ContextMenu(xbmcgui.WindowXMLDialog): if action in (ACTION_SELECT_ITEM, ACTION_MOUSE_LEFT_CLICK): if self.getFocusId() == LIST: option = self.list_.getSelectedItem() - self.selected_option = option.getLabel().decode('utf-8') + self.selected_option = option.getLabel() LOG.info('option selected: %s', self.selected_option) self.close() def _add_editcontrol(self, x, y, height, width, password=None): media = path_ops.path.join( v.ADDON_PATH, 'resources', 'skins', 'default', 'media') - filename = utils.try_encode(path_ops.path.join(media, 'white.png')) + filename = path_ops.path.join(media, 'white.png') control = xbmcgui.ControlImage(0, 0, 0, 0, filename=filename, aspectRatio=0, diff --git a/resources/lib/plexbmchelper/plexgdm.py b/resources/lib/plexbmchelper/plexgdm.py index 02d2a54c..1671167e 100644 --- a/resources/lib/plexbmchelper/plexgdm.py +++ b/resources/lib/plexbmchelper/plexgdm.py @@ -155,6 +155,7 @@ class plexgdm(object): while self._registration_is_running: try: data, addr = update_sock.recvfrom(1024) + data = data.decode() log.debug("Recieved UDP packet from [%s] containing [%s]" % (addr, data.strip())) except socket.error: diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 6efb6a19..6e79fc39 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -320,31 +320,15 @@ def cast(func, value): def extend_url(url, params): """ - Pass in an url [unicode] and params [dict]. Returns the extended url + Pass in an url [string] and params [dict]. Returns the extended url '' - in unicode + in string """ - params = encode_dict(params) if params else {} - params = urllib.parse.urlencode(params).decode('utf-8') + params = urllib.parse.urlencode(params) if '?' in url: - return '%s&%s' % (url, params) + return f'{url}&{params}' else: - return '%s?%s' % (url, params) - - -def encode_dict(dictionary): - """ - Pass in a dict. Will return the same dict with all keys and values encoded - in utf-8 - as long as they are unicode. Ignores all non-unicode entries - - Useful for urllib.urlencode or urllib.(un)quote - """ - for key, value in dictionary.items(): - if isinstance(key, str): - dictionary[key.encode('utf-8')] = dictionary.pop(key) - if isinstance(value, str): - dictionary[key] = value.encode('utf-8') - return dictionary + return f'{url}?{params}' def parse_qs(qs, keep_blank_values=0, strict_parsing=0):