added the last time sync run (-5 min)

This commit is contained in:
shaun 2015-08-01 12:21:01 +10:00
parent 368c474ce9
commit 327d790095

View file

@ -72,9 +72,13 @@ class LibrarySync(threading.Thread):
du = DownloadUtils()
# yyyy-MM-ddThh:mm:ssZ
# TODO: save the last sync time/date and use it in the query
url = "{server}/Emby.Kodi.SyncQueue/{UserId}/2015-01-01T00:00:00Z/GetItems?format=json"
lastSync = addon.getSetting("LastIncrenetalSync")
if(lastSync == None or len(lastSync) == 0):
lastSync = "2010-01-01T00:00:00Z"
utils.logMsg("Sync Database", "Incremental Sync Setting Last Run Time Loaded : " + lastSync, 0)
url = "{server}/Emby.Kodi.SyncQueue/{UserId}/" + lastSync + "/GetItems?format=json"
utils.logMsg("Sync Database", "Incremental Sync Get Items URL : " + url, 0)
results = du.downloadUrl(url)
utils.logMsg("Sync Database", "Incfemental Sync Changes : " + str(results), 0)
@ -89,6 +93,11 @@ class LibrarySync(threading.Thread):
LibrarySync().update_items(changedItems)
LibrarySync().user_data_update(userChanges)
# save last sync time
lastSync = (datetime.utcnow() - timedelta(minutes=5)).strftime('%Y-%m-%dT%H:%M:%SZ')
utils.logMsg("Sync Database", "Incremental Sync Setting Last Run Time Saved : " + lastSync, 0)
addon.setSetting("LastIncrenetalSync", lastSync)
return True
#set some variable to check if this is the first run