From cdb576517e124c4dcc7e43f90cb17327960c588d Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 5 Mar 2017 14:02:58 +0100 Subject: [PATCH 1/3] Fix UnicodeEncodeError - Fixes #244 --- resources/lib/playlist_func.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 6714c900..63cd994d 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -36,7 +36,7 @@ class Playlist_Object_Baseclase(object): answ += "items: %s, " % self.items for key in self.__dict__: if key not in ("ID", 'items'): - answ += '%s: %s, ' % (key, tryDecode(str(getattr(self, key)))) + answ += '%s: %s, ' % (key, tryEncode(str(getattr(self, key)))) return answ[:-2] + ">" def clear(self): @@ -80,7 +80,7 @@ class Playlist_Item(object): def __repr__(self): answ = "<%s: " % (self.__class__.__name__) for key in self.__dict__: - answ += '%s: %s, ' % (key, tryDecode(str(getattr(self, key)))) + answ += '%s: %s, ' % (key, tryEncode(str(getattr(self, key)))) return answ[:-2] + ">" From d5e19c532835155a214ece24952279d168dd70da Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 5 Mar 2017 15:06:54 +0100 Subject: [PATCH 2/3] Cleanup playlist/playqueue string/unicode - Fixes #244 --- resources/lib/playlist_func.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 63cd994d..dc0268c7 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -36,7 +36,11 @@ class Playlist_Object_Baseclase(object): answ += "items: %s, " % self.items for key in self.__dict__: if key not in ("ID", 'items'): - answ += '%s: %s, ' % (key, tryEncode(str(getattr(self, key)))) + if type(getattr(self, key)) in (str, unicode): + answ += '%s: %s, ' % (key, tryEncode(getattr(self, key))) + else: + # e.g. int + answ += '%s: %s, ' % (key, str(getattr(self, key))) return answ[:-2] + ">" def clear(self): @@ -73,14 +77,18 @@ class Playlist_Item(object): plex_UUID = None # Plex librarySectionUUID kodi_id = None # Kodi unique kodi id (unique only within type!) kodi_type = None # Kodi type: 'movie' - file = None # Path to the item's file - uri = None # Weird Plex uri path involving plex_UUID + file = None # Path to the item's file. STRING!! + uri = None # Weird Plex uri path involving plex_UUID. STRING! guid = None # Weird Plex guid def __repr__(self): answ = "<%s: " % (self.__class__.__name__) for key in self.__dict__: - answ += '%s: %s, ' % (key, tryEncode(str(getattr(self, key)))) + if type(getattr(self, key)) in (str, unicode): + answ += '%s: %s, ' % (key, tryEncode(getattr(self, key))) + else: + # e.g. int + answ += '%s: %s, ' % (key, str(getattr(self, key))) return answ[:-2] + ">" @@ -258,6 +266,8 @@ def add_listitem_to_playlist(playlist, pos, listitem, kodi_id=None, Adds a listitem to both the Kodi and Plex playlist at position pos [int]. If file is not None, file will overrule kodi_id! + + file: str!! """ log.debug('add_listitem_to_playlist at position %s. Playlist before add: ' '%s' % (pos, playlist)) @@ -285,6 +295,8 @@ def add_item_to_playlist(playlist, pos, kodi_id=None, kodi_type=None, plex_id=None, file=None): """ Adds an item to BOTH the Kodi and Plex playlist at position pos [int] + + file: str! """ log.debug('add_item_to_playlist. Playlist before adding: %s' % playlist) kodi_item = {'id': kodi_id, 'type': kodi_type, 'file': file} @@ -349,6 +361,8 @@ def add_item_to_kodi_playlist(playlist, pos, kodi_id=None, kodi_type=None, Adds an item to the KODI playlist only. WILL ALSO UPDATE OUR PLAYLISTS Returns False if unsuccessful + + file: str! """ log.debug('Adding new item kodi_id: %s, kodi_type: %s, file: %s to Kodi ' 'only at position %s for %s' @@ -496,7 +510,7 @@ def add_to_Kodi_playlist(playlist, xml_video_element): if item.kodi_id: params['item'] = {'%sid' % item.kodi_type: item.kodi_id} else: - params['item'] = {'file': tryEncode(item.file)} + params['item'] = {'file': item.file} reply = JSONRPC('Playlist.Add').execute(params) if reply.get('error') is not None: log.error('Could not add item %s to Kodi playlist. Error: %s' @@ -512,6 +526,8 @@ def add_listitem_to_Kodi_playlist(playlist, pos, listitem, file, Adds an xbmc listitem to the Kodi playlist.xml_video_element WILL NOT UPDATE THE PLEX SIDE, BUT WILL UPDATE OUR PLAYLISTS + + file: string! """ log.debug('Insert listitem at position %s for Kodi only for %s' % (pos, playlist)) From fa45e8dee8692fada098f3788dd355f96836c334 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 5 Mar 2017 15:08:24 +0100 Subject: [PATCH 3/3] Version bump --- addon.xml | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 0e45d456..678e5bcc 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index d9c70b6b..955b0a9a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +version 1.6.3 +- Fix UnicodeEncodeError for non ASCII filenames in playback_starter +- Cleanup playlist/playqueue string/unicode + version 1.6.2 - Fix Plex Web Issue, thanks @AllanMar - Fix TypeError on manually entering PMS port