Fix some IndexErrors and KeyErrors

This commit is contained in:
croneter 2017-12-13 20:41:29 +01:00
parent 9cac51d5c9
commit 80c106d57f
2 changed files with 7 additions and 5 deletions

View file

@ -17,7 +17,7 @@ from PlexFunctions import init_plex_playqueue
from PKC_listitem import PKC_ListItem as ListItem, convert_PKC_to_listitem from PKC_listitem import PKC_ListItem as ListItem, convert_PKC_to_listitem
from playlist_func import add_item_to_kodi_playlist, \ from playlist_func import add_item_to_kodi_playlist, \
get_playlist_details_from_xml, add_listitem_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 pickler import Playback_Successful
from plexdb_functions import Get_Plex_DB from plexdb_functions import Get_Plex_DB
import variables as v import variables as v
@ -140,6 +140,7 @@ class PlaybackUtils():
get_playlist_details_from_xml(playqueue, xml=xml) get_playlist_details_from_xml(playqueue, xml=xml)
except KeyError: except KeyError:
return return
playqueue.items.append(playlist_item_from_xml(playqueue, xml[0]))
if (not homeScreen and not seektime and sizePlaylist < 2 and if (not homeScreen and not seektime and sizePlaylist < 2 and
window('plex_customplaylist') != "true" and window('plex_customplaylist') != "true" and

View file

@ -90,7 +90,6 @@ class SubscriptionManager:
def _get_container_key(self, playerid): def _get_container_key(self, playerid):
key = None key = None
playlistid = state.PLAYER_STATES[playerid]['playlistid'] playlistid = state.PLAYER_STATES[playerid]['playlistid']
LOG.debug('type: %s, playlistid: %s', type(playlistid), playlistid)
if playlistid != -1: if playlistid != -1:
# -1 is Kodi's answer if there is no playlist # -1 is Kodi's answer if there is no playlist
try: try:
@ -198,7 +197,8 @@ class SubscriptionManager:
def _get_pms_params(self, playerid): def _get_pms_params(self, playerid):
info = state.PLAYER_STATES[playerid] info = state.PLAYER_STATES[playerid]
status = 'paused' if info['speed'] == '0' else 'playing' status = 'paused' if info['speed'] == '0' else 'playing'
params = {'state': status, params = {
'state': status,
'ratingKey': self.ratingkey, 'ratingKey': self.ratingkey,
'key': '/library/metadata/%s' % self.ratingkey, 'key': '/library/metadata/%s' % self.ratingkey,
'time': kodi_time_to_millis(info['time']), 'time': kodi_time_to_millis(info['time']),
@ -208,8 +208,9 @@ class SubscriptionManager:
params['containerKey'] = self.containerKey params['containerKey'] = self.containerKey
if self.containerKey is not None and \ if self.containerKey is not None and \
self.containerKey.startswith('/playQueues/'): self.containerKey.startswith('/playQueues/'):
params['playQueueVersion'] = info['playQueueVersion'] playqueue = self.playqueue.playqueues[playerid]
params['playQueueItemID'] = info['playQueueItemID'] params['playQueueVersion'] = playqueue.version
params['playQueueItemID'] = playqueue.id
self.last_params = params self.last_params = params
return params return params