From 80c106d57fd22b8b6806d924af6a041208fae470 Mon Sep 17 00:00:00 2001 From: croneter Date: Wed, 13 Dec 2017 20:41:29 +0100 Subject: [PATCH] Fix some IndexErrors and KeyErrors --- resources/lib/playbackutils.py | 3 ++- resources/lib/plexbmchelper/subscribers.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index ea8e9e27..6ff63e09 100644 --- a/resources/lib/playbackutils.py +++ b/resources/lib/playbackutils.py @@ -17,7 +17,7 @@ from PlexFunctions import init_plex_playqueue from PKC_listitem import PKC_ListItem as ListItem, convert_PKC_to_listitem from playlist_func import add_item_to_kodi_playlist, \ get_playlist_details_from_xml, add_listitem_to_Kodi_playlist, \ - add_listitem_to_playlist, remove_from_kodi_playlist + add_listitem_to_playlist, remove_from_kodi_playlist, playlist_item_from_xml from pickler import Playback_Successful from plexdb_functions import Get_Plex_DB import variables as v @@ -140,6 +140,7 @@ class PlaybackUtils(): get_playlist_details_from_xml(playqueue, xml=xml) except KeyError: return + playqueue.items.append(playlist_item_from_xml(playqueue, xml[0])) if (not homeScreen and not seektime and sizePlaylist < 2 and window('plex_customplaylist') != "true" and diff --git a/resources/lib/plexbmchelper/subscribers.py b/resources/lib/plexbmchelper/subscribers.py index d45744d3..c0e20418 100644 --- a/resources/lib/plexbmchelper/subscribers.py +++ b/resources/lib/plexbmchelper/subscribers.py @@ -90,7 +90,6 @@ class SubscriptionManager: def _get_container_key(self, playerid): key = None playlistid = state.PLAYER_STATES[playerid]['playlistid'] - LOG.debug('type: %s, playlistid: %s', type(playlistid), playlistid) if playlistid != -1: # -1 is Kodi's answer if there is no playlist try: @@ -198,7 +197,8 @@ class SubscriptionManager: def _get_pms_params(self, playerid): info = state.PLAYER_STATES[playerid] status = 'paused' if info['speed'] == '0' else 'playing' - params = {'state': status, + params = { + 'state': status, 'ratingKey': self.ratingkey, 'key': '/library/metadata/%s' % self.ratingkey, 'time': kodi_time_to_millis(info['time']), @@ -208,8 +208,9 @@ class SubscriptionManager: params['containerKey'] = self.containerKey if self.containerKey is not None and \ self.containerKey.startswith('/playQueues/'): - params['playQueueVersion'] = info['playQueueVersion'] - params['playQueueItemID'] = info['playQueueItemID'] + playqueue = self.playqueue.playqueues[playerid] + params['playQueueVersion'] = playqueue.version + params['playQueueItemID'] = playqueue.id self.last_params = params return params