Better error handling for Plex Companion

- Partially fixes #233
This commit is contained in:
tomkat83 2017-02-26 16:29:19 +01:00
parent b70a3331e0
commit f8bfb981ef

View file

@ -290,16 +290,19 @@ class PlaybackUtils():
self.currentPosition = 0 self.currentPosition = 0
for item in self.xml: for item in self.xml:
api = API(item) api = API(item)
successful = True
if api.getType() == v.PLEX_TYPE_CLIP: if api.getType() == v.PLEX_TYPE_CLIP:
self.add_trailer(item) self.add_trailer(item)
else: else:
with Get_Plex_DB() as plex_db: with Get_Plex_DB() as plex_db:
db_item = plex_db.getItem_byId(api.getRatingKey()) db_item = plex_db.getItem_byId(api.getRatingKey())
if db_item is not None: if db_item is not None:
if add_item_to_kodi_playlist(self.playqueue, successful = add_item_to_kodi_playlist(
self.playqueue,
self.currentPosition, self.currentPosition,
kodi_id=db_item[0], kodi_id=db_item[0],
kodi_type=db_item[4]) is True: kodi_type=db_item[4])
if successful is True:
self.currentPosition += 1 self.currentPosition += 1
if len(item[0]) > 1: if len(item[0]) > 1:
self.add_part(item, self.add_part(item,
@ -309,6 +312,7 @@ class PlaybackUtils():
else: else:
# Item not in Kodi DB # Item not in Kodi DB
self.add_trailer(item) self.add_trailer(item)
if successful is True:
self.playqueue.items[self.currentPosition - 1].ID = item.get( self.playqueue.items[self.currentPosition - 1].ID = item.get(
'%sItemID' % self.playqueue.kind) '%sItemID' % self.playqueue.kind)