mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
first cut at using the new server plugin to do start up sync
This commit is contained in:
parent
90c7d68d15
commit
9903b8d53d
2 changed files with 30 additions and 6 deletions
|
@ -59,15 +59,38 @@ class LibrarySync(threading.Thread):
|
||||||
|
|
||||||
def FullLibrarySync(self,manualRun=False):
|
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"
|
startupDone = WINDOW.getProperty("startup") == "done"
|
||||||
syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true"
|
syncInstallRunDone = addon.getSetting("SyncInstallRunDone") == "true"
|
||||||
performMusicSync = addon.getSetting("enableMusicSync") == "true"
|
performMusicSync = addon.getSetting("enableMusicSync") == "true"
|
||||||
dbSyncIndication = addon.getSetting("dbSyncIndication") == "true"
|
dbSyncIndication = addon.getSetting("dbSyncIndication") == "true"
|
||||||
WINDOW.setProperty("SyncDatabaseRunning", "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
|
#show the progress dialog
|
||||||
pDialog = None
|
pDialog = None
|
||||||
|
@ -757,7 +780,7 @@ class LibrarySync(threading.Thread):
|
||||||
if(len(itemsToUpdate) > 0):
|
if(len(itemsToUpdate) > 0):
|
||||||
self.logMsg("Doing LibraryChanged : Processing Added and Updated : " + str(itemsToUpdate), 0)
|
self.logMsg("Doing LibraryChanged : Processing Added and Updated : " + str(itemsToUpdate), 0)
|
||||||
self.updateItems.extend(itemsToUpdate)
|
self.updateItems.extend(itemsToUpdate)
|
||||||
|
|
||||||
def user_data_update(self, userDataList):
|
def user_data_update(self, userDataList):
|
||||||
# websocket client
|
# websocket client
|
||||||
for userData in userDataList:
|
for userData in userDataList:
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
<setting id="dbSyncIndication" type="bool" label="Show sync progress on screen" default="false" visible="true" enable="true" />
|
<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="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="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>
|
||||||
<category label="Playback"> <!-- Extra Sync options -->
|
<category label="Playback"> <!-- Extra Sync options -->
|
||||||
<setting id="smbusername" type="text" label="30007" default="" visible="true" enable="true" />
|
<setting id="smbusername" type="text" label="30007" default="" visible="true" enable="true" />
|
||||||
|
|
Loading…
Reference in a new issue