From 546e79d9254be5be3c82929f0bcda66271286dea Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 3 Jan 2018 17:50:01 +0100 Subject: [PATCH] Move propertiesPlayback from window to state.py --- resources/lib/playbackutils.py | 11 +++++------ resources/lib/player.py | 2 +- resources/lib/state.py | 4 ++++ service.py | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index cf5dee55..d140feef 100644 --- a/resources/lib/playbackutils.py +++ b/resources/lib/playbackutils.py @@ -97,7 +97,6 @@ class PlaybackUtils(): startPos = max(playqueue.kodi_pl.getposition(), 0) self.currentPosition = startPos - propertiesPlayback = window('plex_playbackProps') == "true" introsPlaylist = False dummyPlaylist = False @@ -114,8 +113,8 @@ class PlaybackUtils(): # We need to ensure we add the intro and additional parts only once. # Otherwise we get a loop. - if not propertiesPlayback: - window('plex_playbackProps', value="true") + if not v.PLAYBACK_SETUP_DONE: + v.PLAYBACK_SETUP_DONE = True LOG.info("Setting up properties in playlist.") # Where will the player need to start? # Do we need to get trailers? @@ -232,9 +231,9 @@ class PlaybackUtils(): return result # We just skipped adding properties. Reset flag for next time. - elif propertiesPlayback: + elif v.PLAYBACK_SETUP_DONE: LOG.debug("Resetting properties playback flag.") - window('plex_playbackProps', clear=True) + v.PLAYBACK_SETUP_DONE = False # SETUP MAIN ITEM ########## # For transcoding only, ask for audio/subs pref @@ -277,7 +276,7 @@ class PlaybackUtils(): Play all items contained in the xml passed in. Called by Plex Companion """ LOG.info("Playbackutils play_all called") - window('plex_playbackProps', value="true") + v.PLAYBACK_SETUP_DONE = True self.currentPosition = 0 for item in self.xml: api = API(item) diff --git a/resources/lib/player.py b/resources/lib/player.py index 63071e91..1df9bf24 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -263,12 +263,12 @@ class PKC_Player(Player): for item in ('plex_currently_playing_itemid', 'plex_customplaylist', 'plex_customplaylist.seektime', - 'plex_playbackProps', 'plex_forcetranscode'): window(item, clear=True) # 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) state.PLEX_TRANSIENT_TOKEN = None + v.PLAYBACK_SETUP_DONE = False LOG.debug("Cleared playlist properties.") def onPlayBackEnded(self): diff --git a/resources/lib/state.py b/resources/lib/state.py index 931a5227..a9dc091c 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -117,6 +117,10 @@ PLAYER_STATES = { # paths for playback (since we're not receiving a Kodi id) PLEX_IDS = {} PLAYED_INFO = {} +# Former playbackProps; used by playbackutils.py and set to True if initial +# playback setup has been done (and playbackutils will be called again +# subsequently) +PLAYBACK_SETUP_DONE = False # Kodi webserver details WEBSERVER_PORT = 8080 diff --git a/service.py b/service.py index 06dd1ab9..8f7e6a38 100644 --- a/service.py +++ b/service.py @@ -108,7 +108,7 @@ class Service(): "plex_online", "plex_serverStatus", "plex_onWake", "plex_kodiScan", "plex_shouldStop", "plex_dbScan", - "plex_initialScan", "plex_customplayqueue", "plex_playbackProps", + "plex_initialScan", "plex_customplayqueue", "pms_token", "plex_token", "pms_server", "plex_machineIdentifier", "plex_servername", "plex_authenticated", "PlexUserImage", "useDirectPaths",