Periodically check if PMS address has changed

- Fixes #33
This commit is contained in:
tomkat83 2016-05-29 20:00:14 +02:00
parent 6b329fbb02
commit 6860fe502e

View file

@ -127,7 +127,8 @@ class Service():
kodiProfile = xbmc.translatePath("special://profile") kodiProfile = xbmc.translatePath("special://profile")
# Server auto-detect # Server auto-detect
initialsetup.InitialSetup().setup() setup = initialsetup.InitialSetup()
setup.setup()
# Queue for background sync # Queue for background sync
queue = Queue.Queue(maxsize=200) queue = Queue.Queue(maxsize=200)
@ -145,6 +146,7 @@ class Service():
# Sync and progress report # Sync and progress report
lastProgressUpdate = datetime.today() lastProgressUpdate = datetime.today()
counter = 0
while not monitor.abortRequested(): while not monitor.abortRequested():
if window('emby_kodiProfile') != kodiProfile: if window('emby_kodiProfile') != kodiProfile:
@ -267,8 +269,16 @@ class Service():
"plexkodiconnect/icon.png", "plexkodiconnect/icon.png",
sound=False) sound=False)
self.server_online = False self.server_online = False
counter += 1
# Periodically check if the IP changed, e.g. per minute
if counter > 30:
counter = 0
tmp = setup.PickPMS()
if tmp is not None:
setup.WritePMStoSettings(tmp)
else: else:
# Server is online # Server is online
counter = 0
if not self.server_online: if not self.server_online:
# Server was offline when Kodi started. # Server was offline when Kodi started.
# Wait for server to be fully established. # Wait for server to be fully established.
@ -281,7 +291,7 @@ class Service():
message=lang(33003), message=lang(33003),
icon="special://home/addons/plugin.video." icon="special://home/addons/plugin.video."
"plexkodiconnect/icon.png", "plexkodiconnect/icon.png",
time=2000, time=5000,
sound=False) sound=False)
self.server_online = True self.server_online = True
log("Server %s is online and ready." % server, 1) log("Server %s is online and ready." % server, 1)
@ -298,10 +308,9 @@ class Service():
break break
if monitor.waitForAbort(1): if monitor.waitForAbort(2):
# Abort was requested while waiting. # Abort was requested while waiting.
break break
xbmc.sleep(50)
if monitor.waitForAbort(1): if monitor.waitForAbort(1):
# Abort was requested while waiting. We should exit # Abort was requested while waiting. We should exit