mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
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 = {}
|
||||
|
||||
isFastSync = False
|
||||
|
||||
stop_thread = False
|
||||
suspend_thread = False
|
||||
|
||||
|
@ -87,6 +89,7 @@ class LibrarySync(threading.Thread):
|
|||
for plugin in result:
|
||||
if plugin['Name'] == "Emby.Kodi Sync Queue":
|
||||
log.debug("Found server plugin.")
|
||||
self.isFastSync = True
|
||||
completed = self.fastSync()
|
||||
break
|
||||
|
||||
|
@ -152,14 +155,17 @@ class LibrarySync(threading.Thread):
|
|||
# Save last sync time
|
||||
overlap = 2
|
||||
|
||||
result = self.doUtils("{server}/emby/Emby.Kodi.SyncQueue/GetServerDateTime?format=json")
|
||||
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 = utils.convertDate(server_time)
|
||||
else:
|
||||
raise Exception("Fast sync server plugin is not enabled.")
|
||||
|
||||
except Exception as e:
|
||||
# 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)
|
||||
lastSync = time_now.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
log.info("New sync time: client time -%s min: %s" % (overlap, lastSync))
|
||||
|
|
Loading…
Reference in a new issue