From 60f7d0fce245442e455ff96124ee07978dcc7f64 Mon Sep 17 00:00:00 2001 From: croneter Date: Thu, 25 Oct 2018 18:28:41 +0200 Subject: [PATCH] Don't cast to unicode --- resources/lib/library_sync/full_sync.py | 4 ++-- resources/lib/library_sync/process_metadata.py | 3 +-- resources/lib/library_sync/sections.py | 7 +++---- resources/lib/plex_api.py | 12 ++++++------ 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 712ead5d..12e92160 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -122,9 +122,9 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin): queue_info = process_metadata.InitNewSection( self.context, utils.cast(int, iterator.get('totalSize', 0)), - utils.cast(unicode, iterator.get('librarySectionTitle')), + iterator.get('librarySectionTitle'), section['section_id'], - utils.cast(unicode, section['plex_type'])) + section['plex_type']) self.queue.put(queue_info) for xml_item in iterator: if self.isCanceled(): diff --git a/resources/lib/library_sync/process_metadata.py b/resources/lib/library_sync/process_metadata.py index 60259be5..4f84256b 100644 --- a/resources/lib/library_sync/process_metadata.py +++ b/resources/lib/library_sync/process_metadata.py @@ -103,8 +103,7 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin): notify=True, cancel_sync=True) if self.current % 20 == 0: - self.title = utils.cast(unicode, - item['xml'][0].get('title')) + self.title = item['xml'][0].get('title') self.update() self.current += 1 self.queue.task_done() diff --git a/resources/lib/library_sync/sections.py b/resources/lib/library_sync/sections.py index 7227bcac..fd845a4f 100644 --- a/resources/lib/library_sync/sections.py +++ b/resources/lib/library_sync/sections.py @@ -48,8 +48,7 @@ def sync_from_pms(): if (section.attrib['type'] in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW, v.PLEX_TYPE_PHOTO, v.PLEX_TYPE_ARTIST)): - sorted_sections.append(cast(unicode, - section.attrib['title'])) + sorted_sections.append(section.attrib['title']) LOG.debug('Sorted sections: %s', sorted_sections) totalnodes = len(sorted_sections) @@ -81,14 +80,14 @@ def sync_from_pms(): def _process_section(section_xml, kodi_db, plexdb, sorted_sections, old_sections, totalnodes): folder = section_xml.attrib - plex_type = cast(unicode, folder['type']) + plex_type = folder['type'] # Only process supported formats if plex_type not in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW, v.PLEX_TYPE_ARTIST, v.PLEX_TYPE_PHOTO): LOG.error('Unsupported Plex section type: %s', folder) return totalnodes section_id = cast(int, folder['key']) - section_name = cast(unicode, folder['title']) + section_name = folder['title'] global PLAYLISTS, NODES # Prevent duplicate for nodes of the same type nodes = NODES[plex_type] diff --git a/resources/lib/plex_api.py b/resources/lib/plex_api.py index 2eb66b99..2c94a40b 100644 --- a/resources/lib/plex_api.py +++ b/resources/lib/plex_api.py @@ -482,14 +482,14 @@ class API(object): """ Returns the title of the element as unicode or 'Missing Title Name' """ - return cast(unicode, self.item.get('title', 'Missing Title Name')) + return self.item.get('title', 'Missing Title Name') def sorttitle(self): """ Returns an item's sorting name/title or the title itself if not found "Missing Title" if both are not present """ - return cast(unicode, self.item.get('titleSort', self.item.get('title', 'Missing Title'))) + return self.item.get('titleSort', self.item.get('title', 'Missing Title')) def artist_name(self): """ @@ -502,7 +502,7 @@ class API(object): """ Returns the plot or None. """ - return cast(unicode, self.item.get('summary')) + return self.item.get('summary') def shortplot(self): """ @@ -520,7 +520,7 @@ class API(object): """ Returns a shorter tagline or None """ - return cast(unicode, self.item.get('tagline')) + return self.item.get('tagline') def audience_rating(self): """ @@ -617,7 +617,7 @@ class API(object): """ Returns the 'studio' or None """ - return self.replace_studio(cast(unicode, self.item.get('studio'))) + return self.replace_studio(self.item.get('studio')) def music_studio_list(self): """ @@ -686,7 +686,7 @@ class API(object): """ return (cast(int, self.item.get('grandparentRatingKey')), cast(int, self.item.get('parentRatingKey')), - cast(unicode, self.item.get('grandparentTitle')), + self.item.get('grandparentTitle'), cast(int, self.item.get('parentIndex')), cast(int, self.item.get('index')))