Don't cast to unicode

This commit is contained in:
croneter 2018-10-25 18:28:41 +02:00
parent 0dfcebbee3
commit 60f7d0fce2
4 changed files with 12 additions and 14 deletions

View file

@ -122,9 +122,9 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
queue_info = process_metadata.InitNewSection( queue_info = process_metadata.InitNewSection(
self.context, self.context,
utils.cast(int, iterator.get('totalSize', 0)), utils.cast(int, iterator.get('totalSize', 0)),
utils.cast(unicode, iterator.get('librarySectionTitle')), iterator.get('librarySectionTitle'),
section['section_id'], section['section_id'],
utils.cast(unicode, section['plex_type'])) section['plex_type'])
self.queue.put(queue_info) self.queue.put(queue_info)
for xml_item in iterator: for xml_item in iterator:
if self.isCanceled(): if self.isCanceled():

View file

@ -103,8 +103,7 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin):
notify=True, notify=True,
cancel_sync=True) cancel_sync=True)
if self.current % 20 == 0: if self.current % 20 == 0:
self.title = utils.cast(unicode, self.title = item['xml'][0].get('title')
item['xml'][0].get('title'))
self.update() self.update()
self.current += 1 self.current += 1
self.queue.task_done() self.queue.task_done()

View file

@ -48,8 +48,7 @@ def sync_from_pms():
if (section.attrib['type'] in if (section.attrib['type'] in
(v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW, v.PLEX_TYPE_PHOTO, (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW, v.PLEX_TYPE_PHOTO,
v.PLEX_TYPE_ARTIST)): v.PLEX_TYPE_ARTIST)):
sorted_sections.append(cast(unicode, sorted_sections.append(section.attrib['title'])
section.attrib['title']))
LOG.debug('Sorted sections: %s', sorted_sections) LOG.debug('Sorted sections: %s', sorted_sections)
totalnodes = len(sorted_sections) totalnodes = len(sorted_sections)
@ -81,14 +80,14 @@ def sync_from_pms():
def _process_section(section_xml, kodi_db, plexdb, sorted_sections, def _process_section(section_xml, kodi_db, plexdb, sorted_sections,
old_sections, totalnodes): old_sections, totalnodes):
folder = section_xml.attrib folder = section_xml.attrib
plex_type = cast(unicode, folder['type']) plex_type = folder['type']
# Only process supported formats # Only process supported formats
if plex_type not in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW, if plex_type not in (v.PLEX_TYPE_MOVIE, v.PLEX_TYPE_SHOW,
v.PLEX_TYPE_ARTIST, v.PLEX_TYPE_PHOTO): v.PLEX_TYPE_ARTIST, v.PLEX_TYPE_PHOTO):
LOG.error('Unsupported Plex section type: %s', folder) LOG.error('Unsupported Plex section type: %s', folder)
return totalnodes return totalnodes
section_id = cast(int, folder['key']) section_id = cast(int, folder['key'])
section_name = cast(unicode, folder['title']) section_name = folder['title']
global PLAYLISTS, NODES global PLAYLISTS, NODES
# Prevent duplicate for nodes of the same type # Prevent duplicate for nodes of the same type
nodes = NODES[plex_type] nodes = NODES[plex_type]

View file

@ -482,14 +482,14 @@ class API(object):
""" """
Returns the title of the element as unicode or 'Missing Title Name' 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): def sorttitle(self):
""" """
Returns an item's sorting name/title or the title itself if not found Returns an item's sorting name/title or the title itself if not found
"Missing Title" if both are not present "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): def artist_name(self):
""" """
@ -502,7 +502,7 @@ class API(object):
""" """
Returns the plot or None. Returns the plot or None.
""" """
return cast(unicode, self.item.get('summary')) return self.item.get('summary')
def shortplot(self): def shortplot(self):
""" """
@ -520,7 +520,7 @@ class API(object):
""" """
Returns a shorter tagline or None Returns a shorter tagline or None
""" """
return cast(unicode, self.item.get('tagline')) return self.item.get('tagline')
def audience_rating(self): def audience_rating(self):
""" """
@ -617,7 +617,7 @@ class API(object):
""" """
Returns the 'studio' or None 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): def music_studio_list(self):
""" """
@ -686,7 +686,7 @@ class API(object):
""" """
return (cast(int, self.item.get('grandparentRatingKey')), return (cast(int, self.item.get('grandparentRatingKey')),
cast(int, self.item.get('parentRatingKey')), 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('parentIndex')),
cast(int, self.item.get('index'))) cast(int, self.item.get('index')))