Keep track of fast sync
If server plugin is not installed, automatically fall back to client time.
This commit is contained in:
parent
46121656f8
commit
f4a80a5ea8
1 changed files with 10 additions and 4 deletions
|
@ -33,6 +33,8 @@ class LibrarySync(threading.Thread):
|
||||||
|
|
||||||
_shared_state = {}
|
_shared_state = {}
|
||||||
|
|
||||||
|
isFastSync = False
|
||||||
|
|
||||||
stop_thread = False
|
stop_thread = False
|
||||||
suspend_thread = False
|
suspend_thread = False
|
||||||
|
|
||||||
|
@ -87,6 +89,7 @@ class LibrarySync(threading.Thread):
|
||||||
for plugin in result:
|
for plugin in result:
|
||||||
if plugin['Name'] == "Emby.Kodi Sync Queue":
|
if plugin['Name'] == "Emby.Kodi Sync Queue":
|
||||||
log.debug("Found server plugin.")
|
log.debug("Found server plugin.")
|
||||||
|
self.isFastSync = True
|
||||||
completed = self.fastSync()
|
completed = self.fastSync()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -152,14 +155,17 @@ class LibrarySync(threading.Thread):
|
||||||
# Save last sync time
|
# Save last sync time
|
||||||
overlap = 2
|
overlap = 2
|
||||||
|
|
||||||
result = self.doUtils("{server}/emby/Emby.Kodi.SyncQueue/GetServerDateTime?format=json")
|
|
||||||
try: # datetime fails when used more than once, TypeError
|
try: # datetime fails when used more than once, TypeError
|
||||||
|
if isFastSync:
|
||||||
|
result = self.doUtils("{server}/emby/Emby.Kodi.SyncQueue/GetServerDateTime?format=json")
|
||||||
server_time = result['ServerDateTime']
|
server_time = result['ServerDateTime']
|
||||||
server_time = utils.convertDate(server_time)
|
server_time = utils.convertDate(server_time)
|
||||||
|
else:
|
||||||
|
raise Exception("Fast sync server plugin is not enabled.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If the server plugin is not installed or an error happened.
|
# If the server plugin is not installed or an error happened.
|
||||||
log.error("An exception occurred: %s" % e)
|
log.debug("An exception occurred: %s" % e)
|
||||||
time_now = datetime.utcnow()-timedelta(minutes=overlap)
|
time_now = datetime.utcnow()-timedelta(minutes=overlap)
|
||||||
lastSync = time_now.strftime('%Y-%m-%dT%H:%M:%SZ')
|
lastSync = time_now.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||||
log.info("New sync time: client time -%s min: %s" % (overlap, lastSync))
|
log.info("New sync time: client time -%s min: %s" % (overlap, lastSync))
|
||||||
|
|
Loading…
Reference in a new issue