Fix PKC synching playstate to wrong user on profile switch
- BUT: Kodi profiles seem to be a mess!
This commit is contained in:
parent
ba4f1d15d6
commit
d068c37c49
1 changed files with 26 additions and 12 deletions
|
@ -451,6 +451,9 @@ class Service(object):
|
||||||
self.choose_plex_libraries()
|
self.choose_plex_libraries()
|
||||||
elif plex_command == 'RESET-PKC':
|
elif plex_command == 'RESET-PKC':
|
||||||
utils.reset()
|
utils.reset()
|
||||||
|
elif plex_command == 'EXIT-PKC':
|
||||||
|
LOG.info('Received command from another instance to quit')
|
||||||
|
app.APP.stop_pkc = True
|
||||||
if task:
|
if task:
|
||||||
backgroundthread.BGThreader.addTasksToFront([task])
|
backgroundthread.BGThreader.addTasksToFront([task])
|
||||||
continue
|
continue
|
||||||
|
@ -506,26 +509,37 @@ class Service(object):
|
||||||
library_sync.clear_window_vars()
|
library_sync.clear_window_vars()
|
||||||
# Will block until threads have quit
|
# Will block until threads have quit
|
||||||
app.APP.stop_threads()
|
app.APP.stop_threads()
|
||||||
utils.window('plex_service_started', clear=True)
|
|
||||||
LOG.info("======== STOP %s ========", v.ADDON_NAME)
|
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
# Safety net - Kody starts PKC twice upon first installation!
|
# Safety net - Kody starts PKC twice upon first installation!
|
||||||
if utils.window('plex_service_started') == 'true':
|
if utils.window('plex_service_started') == 'true':
|
||||||
EXIT = True
|
LOG.info('Another service.py instance is already running - shutting '
|
||||||
else:
|
'it down now')
|
||||||
|
# Telling the other Python instance of PKC to shut down now
|
||||||
|
i = 0
|
||||||
|
while utils.window('plexkodiconnect.command'):
|
||||||
|
xbmc.sleep(20)
|
||||||
|
i += 1
|
||||||
|
if i > 300:
|
||||||
|
LOG.error('Could not tell other PKC instance to shut down')
|
||||||
|
return
|
||||||
|
utils.window('plexkodiconnect.command', value='EXIT-PKC')
|
||||||
|
# Telling successful - now wait for actual shut-down
|
||||||
|
i = 0
|
||||||
|
while utils.window('plex_service_started'):
|
||||||
|
xbmc.sleep(20)
|
||||||
|
i += 1
|
||||||
|
if i > 300:
|
||||||
|
LOG.error('Could not shut down other PKC instance')
|
||||||
|
return
|
||||||
utils.window('plex_service_started', value='true')
|
utils.window('plex_service_started', value='true')
|
||||||
EXIT = False
|
|
||||||
|
|
||||||
# Delay option
|
|
||||||
DELAY = int(utils.settings('startupDelay'))
|
DELAY = int(utils.settings('startupDelay'))
|
||||||
|
|
||||||
LOG.info("Delaying Plex startup by: %s sec...", DELAY)
|
LOG.info("Delaying Plex startup by: %s sec...", DELAY)
|
||||||
if EXIT:
|
if DELAY and xbmc.Monitor().waitForAbort(DELAY):
|
||||||
LOG.error('PKC service.py already started - exiting this instance')
|
|
||||||
elif DELAY and xbmc.Monitor().waitForAbort(DELAY):
|
|
||||||
# Start the service
|
# Start the service
|
||||||
LOG.info("Abort requested while waiting. PKC not started.")
|
LOG.info("Abort requested while waiting. PKC not started.")
|
||||||
else:
|
else:
|
||||||
Service().ServiceEntryPoint()
|
Service().ServiceEntryPoint()
|
||||||
|
utils.window('plex_service_started', clear=True)
|
||||||
|
LOG.info("======== STOP PlexKodiConnect service ========")
|
||||||
|
|
Loading…
Reference in a new issue