ad some limits to the inc sync counts atm its 1K

This commit is contained in:
Shaun 2015-09-05 16:58:39 +10:00
parent 30ea23aea0
commit 53cc2c9c74
2 changed files with 35 additions and 27 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="1.1.35" version="1.1.36"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>

View file

@ -89,22 +89,31 @@ class LibrarySync(threading.Thread):
url = "{server}/Emby.Kodi.SyncQueue/{UserId}/GetItems?LastUpdateDT=" + lastSync + "&format=json" url = "{server}/Emby.Kodi.SyncQueue/{UserId}/GetItems?LastUpdateDT=" + lastSync + "&format=json"
utils.logMsg("Sync Database", "Incremental Sync Get Items URL : " + url, 0) utils.logMsg("Sync Database", "Incremental Sync Get Items URL : " + url, 0)
results = du.downloadUrl(url) try:
utils.logMsg("Sync Database", "Incremental Sync Changes : " + str(results), 0) results = du.downloadUrl(url)
except:
changedItems = results["ItemsUpdated"] + results["ItemsAdded"] utils.logMsg("Sync Database", "Incremental Sync Get Changes Failed", 0)
removedItems = results["ItemsRemoved"] pass
userChanges = results["UserDataChanged"] else:
utils.logMsg("Sync Database", "Incremental Sync Changes : " + str(results), 0)
WINDOW.setProperty("startup", "done")
changedItems = results["ItemsUpdated"] + results["ItemsAdded"]
LibrarySync().remove_items(removedItems) removedItems = results["ItemsRemoved"]
LibrarySync().update_items(changedItems) userChanges = results["UserDataChanged"]
LibrarySync().user_data_update(userChanges)
if(len(changedItems) < 1000 and len(removedItems) < 1000 and len(userChanges) < 1000):
self.SaveLastSync()
WINDOW.setProperty("startup", "done")
return True
LibrarySync().remove_items(removedItems)
LibrarySync().update_items(changedItems)
LibrarySync().user_data_update(userChanges)
self.SaveLastSync()
return True
else:
utils.logMsg("Sync Database", "Too Many For Incremental Sync, changedItems" + str(len(changedItems)) + " removedItems:" + str(len(removedItems)) + " userChanges:" + str(len(userChanges)), 0)
#set some variable to check if this is the first run #set some variable to check if this is the first run
WINDOW.setProperty("SyncDatabaseRunning", "true") WINDOW.setProperty("SyncDatabaseRunning", "true")
@ -171,8 +180,7 @@ class LibrarySync(threading.Thread):
# set the install done setting # set the install done setting
if(syncInstallRunDone == False and completed): if(syncInstallRunDone == False and completed):
utils.settings("SyncInstallRunDone", "true") utils.settings("SyncInstallRunDone", "true")
self.SaveLastSync()
# Commit all DB changes at once and Force refresh the library # Commit all DB changes at once and Force refresh the library
xbmc.executebuiltin("UpdateLibrary(video)") xbmc.executebuiltin("UpdateLibrary(video)")
@ -184,10 +192,11 @@ class LibrarySync(threading.Thread):
# tell any widgets to refresh because the content has changed # tell any widgets to refresh because the content has changed
WINDOW.setProperty("widgetreload", datetime.now().strftime('%Y-%m-%d %H:%M:%S')) WINDOW.setProperty("widgetreload", datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
self.SaveLastSync()
finally: finally:
WINDOW.setProperty("SyncDatabaseRunning", "false") WINDOW.setProperty("SyncDatabaseRunning", "false")
utils.logMsg("Sync DB", "syncDatabase Exiting", 0) utils.logMsg("Sync DB", "syncDatabase Exiting", 0)
if(pDialog != None): if(pDialog != None):
pDialog.close() pDialog.close()
@ -247,18 +256,17 @@ class LibrarySync(threading.Thread):
#### PROCESS BOX SETS ##### #### PROCESS BOX SETS #####
if(pDialog != None): utils.logMsg("Sync Movies", "BoxSet Sync Started", 1)
utils.logMsg("Sync Movies", "BoxSet Sync Started", 1)
boxsets = ReadEmbyDB().getBoxSets() boxsets = ReadEmbyDB().getBoxSets()
total = len(boxsets) + 1 total = len(boxsets) + 1
count = 1 count = 1
for boxset in boxsets: for boxset in boxsets:
progressTitle = "Processing BoxSets"+ " (" + str(count) + " of " + str(total) + ")" if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100)) progressTitle = "Processing BoxSets" + " (" + str(count) + " of " + str(total-1) + ")"
pDialog.update(percentage, "Emby for Kodi - Running Sync", progressTitle) percentage = int(((float(count) / float(total)) * 100))
count += 1 pDialog.update(percentage, "Emby for Kodi - Running Sync", progressTitle)
count += 1
if(self.ShouldStop()): if(self.ShouldStop()):
return False return False
boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"]) boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"])