use retention date from server

This commit is contained in:
Shaun 2016-02-04 17:09:35 +11:00
parent 452df0614d
commit 95ed199218

View file

@ -105,6 +105,24 @@ class LibrarySync(threading.Thread):
lastSync = "2010-01-01T00:00:00Z"
self.logMsg("Last sync run: %s" % lastSync, 1)
lastSyncTime = datetime.strptime(lastSync, "%Y-%m-%dT%H:%M:%SZ")
self.logMsg("LastIncrementalSync : %s" % lastSyncTime, 1)
# get server RetentionDateTime
url = "{server}/Emby.Kodi.SyncQueue/GetServerDateTime?format=json"
result = self.doUtils.downloadUrl(url)
retention_time = "2010-01-01T00:00:00Z"
if result and result['RetentionDateTime']:
self.logMsg("RetentionDateTime Found", 1)
retention_time = result['RetentionDateTime']
retention_time = datetime.strptime(retention_time, "%Y-%m-%dT%H:%M:%SZ")
self.logMsg("RetentionDateTime : %s" % retention_time, 1)
# if last sync before retention time do a full sync
if retention_time > lastSyncTime:
self.logMsg("Fast sync server retention insurficient, fall back to full sync", 1)
return False
url = "{server}/emby/Emby.Kodi.SyncQueue/{UserId}/GetItems?format=json"
params = {'LastUpdateDT': lastSync}
result = self.doUtils.downloadUrl(url, parameters=params)