Enforce plex id type int
This commit is contained in:
parent
c996e5c9be
commit
20f26364b8
2 changed files with 4 additions and 17 deletions
|
@ -329,7 +329,7 @@ def playlist_item_from_kodi(kodi_item):
|
|||
item.file = kodi_item.get('file')
|
||||
if item.plex_id is None and item.file is not None:
|
||||
query = dict(parse_qsl(urlsplit(item.file).query))
|
||||
item.plex_id = query.get('plex_id')
|
||||
item.plex_id = utils.cast(int, query.get('plex_id'))
|
||||
item.plex_type = query.get('itemType')
|
||||
if item.plex_id is None and item.file is not None:
|
||||
item.uri = ('library://whatever/item/%s'
|
||||
|
|
|
@ -54,19 +54,6 @@ LOG = getLogger('PLEX.plex_api')
|
|||
###############################################################################
|
||||
|
||||
|
||||
def _unicode_or_none(value):
|
||||
"""
|
||||
Tries to decode value to unicode. Returns None if this fails
|
||||
"""
|
||||
try:
|
||||
return value.decode('utf-8')
|
||||
except TypeError:
|
||||
# e.g. Android TV's Python
|
||||
return value.decode()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
class API(object):
|
||||
"""
|
||||
API(item)
|
||||
|
@ -94,7 +81,7 @@ class API(object):
|
|||
Returns the type of media, e.g. 'movie' or 'clip' for trailers as
|
||||
Unicode or None.
|
||||
"""
|
||||
return _unicode_or_none(self.item.get('type'))
|
||||
return self.item.get('type')
|
||||
|
||||
def playlist_type(self):
|
||||
"""
|
||||
|
@ -713,8 +700,8 @@ class API(object):
|
|||
as Unicode.
|
||||
If not found, None is returned
|
||||
"""
|
||||
return _unicode_or_none(self.item.get('playQueueItemID') or
|
||||
self.item.get('playListItemID'))
|
||||
return (cast(int, self.item.get('playQueueItemID')) or
|
||||
cast(int, self.item.get('playListItemID')))
|
||||
|
||||
def _data_from_part_or_media(self, key):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue