Fix playstates not being copied/reset correctly

This commit is contained in:
croneter 2018-03-11 18:54:05 +01:00
parent 8943083533
commit 93e3d42e23
3 changed files with 7 additions and 5 deletions

View file

@ -4,6 +4,7 @@ PKC Kodi Monitoring implementation
from logging import getLogger from logging import getLogger
from json import loads from json import loads
from threading import Thread from threading import Thread
import copy
from xbmc import Monitor, Player, sleep, getCondVisibility, getInfoLabel, \ from xbmc import Monitor, Player, sleep, getCondVisibility, getInfoLabel, \
getLocalizedString getLocalizedString
@ -60,8 +61,8 @@ class KodiMonitor(Monitor):
self.xbmcplayer = Player() self.xbmcplayer = Player()
Monitor.__init__(self) Monitor.__init__(self)
for playerid in state.PLAYER_STATES: for playerid in state.PLAYER_STATES:
state.PLAYER_STATES[playerid] = dict(state.PLAYSTATE) state.PLAYER_STATES[playerid] = copy.deepcopy(state.PLAYSTATE)
state.OLD_PLAYER_STATES[playerid] = dict(state.PLAYSTATE) state.OLD_PLAYER_STATES[playerid] = copy.deepcopy(state.PLAYSTATE)
LOG.info("Kodi monitor started.") LOG.info("Kodi monitor started.")
def onScanStarted(self, library): def onScanStarted(self, library):

View file

@ -2,6 +2,7 @@
############################################################################### ###############################################################################
from logging import getLogger from logging import getLogger
import copy
from xbmc import Player from xbmc import Player
@ -23,9 +24,9 @@ def playback_cleanup():
""" """
PKC cleanup after playback ends/is stopped PKC cleanup after playback ends/is stopped
""" """
LOG.debug('playback_cleanup called')
# We might have saved a transient token from a user flinging media via # We might have saved a transient token from a user flinging media via
# Companion (if we could not use the playqueue to store the token) # Companion (if we could not use the playqueue to store the token)
LOG.debug('playback_cleanup called')
state.PLEX_TRANSIENT_TOKEN = None state.PLEX_TRANSIENT_TOKEN = None
for playerid in state.ACTIVE_PLAYERS: for playerid in state.ACTIVE_PLAYERS:
status = state.PLAYER_STATES[playerid] status = state.PLAYER_STATES[playerid]
@ -38,7 +39,7 @@ def playback_cleanup():
'{server}/video/:/transcode/universal/stop', '{server}/video/:/transcode/universal/stop',
parameters={'session': v.PKC_MACHINE_IDENTIFIER}) parameters={'session': v.PKC_MACHINE_IDENTIFIER})
# Reset the player's status # Reset the player's status
status = dict(state.PLAYSTATE) status = copy.deepcopy(state.PLAYSTATE)
# As all playback has halted, reset the players that have been active # As all playback has halted, reset the players that have been active
state.ACTIVE_PLAYERS = [] state.ACTIVE_PLAYERS = []
LOG.debug('Finished PKC playback cleanup') LOG.debug('Finished PKC playback cleanup')

View file

@ -108,7 +108,7 @@ OLD_PLAYER_STATES = {
1: {}, 1: {},
2: {} 2: {}
} }
# "empty" dict for the PLAYER_STATES above # "empty" dict for the PLAYER_STATES above. Use copy.deepcopy to duplicate!
PLAYSTATE = { PLAYSTATE = {
'type': None, 'type': None,
'time': { 'time': {