first cut at using the new server plugin to do start up sync

This commit is contained in:
Shaun 2015-08-01 10:26:22 +10:00
parent 90c7d68d15
commit 9903b8d53d
2 changed files with 30 additions and 6 deletions

View file

@ -59,15 +59,38 @@ class LibrarySync(threading.Thread):
def FullLibrarySync(self,manualRun=False):
#set some variable to check if this is the first run
addon = xbmcaddon.Addon(id='plugin.video.emby')
addon = xbmcaddon.Addon(id='plugin.video.emby')
startupDone = WINDOW.getProperty("startup") == "done"
syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true"
performMusicSync = addon.getSetting("enableMusicSync") == "true"
dbSyncIndication = addon.getSetting("dbSyncIndication") == "true"
WINDOW.setProperty("SyncDatabaseRunning", "true")
dbSyncIndication = addon.getSetting("dbSyncIndication") == "true"
# just do a incremental sync if that is what is required
if(addon.getSetting("useIncSync") == "true"):
utils.logMsg("Sync Database", "Using incremental sync instead of full sync useIncSync=True)", 0)
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"
results = du.downloadUrl(url)
utils.logMsg("Sync Database", "Incfemental Sync Changes : " + str(results), 0)
changedItems = results["ItemsUpdated"] + results["ItemsAdded"] + results["UserDataChanged"]
removedItems = results["ItemsRemoved"]
WINDOW.setProperty("startup", "done")
LibrarySync().remove_items(removedItems)
LibrarySync().update_items(changedItems)
return True
#set some variable to check if this is the first run
WINDOW.setProperty("SyncDatabaseRunning", "true")
#show the progress dialog
pDialog = None
@ -757,7 +780,7 @@ class LibrarySync(threading.Thread):
if(len(itemsToUpdate) > 0):
self.logMsg("Doing LibraryChanged : Processing Added and Updated : " + str(itemsToUpdate), 0)
self.updateItems.extend(itemsToUpdate)
def user_data_update(self, userDataList):
# websocket client
for userData in userDataList:

View file

@ -20,7 +20,8 @@
<setting id="dbSyncIndication" type="bool" label="Show sync progress on screen" default="false" visible="true" enable="true" />
<setting id="enableMusicSync" type="bool" label="Enable Music Library Sync" default="true" visible="true" enable="true" />
<setting id="useDirectPaths" type="bool" label="30250" default="false" visible="true" enable="true" />
<setting id="enableTextureCache" type="bool" label="Auto add images to the Kodi texture cache" default="true" visible="true" enable="true" />
<setting id="enableTextureCache" type="bool" label="Auto add images to the Kodi texture cache" default="true" visible="true" enable="true" />
<setting id="useIncSync" type="bool" label="Use incremental sync at startup (Requires Server Plugin)" default="false" visible="true" enable="true" />
</category>
<category label="Playback"> <!-- Extra Sync options -->
<setting id="smbusername" type="text" label="30007" default="" visible="true" enable="true" />