optimize playcount sync for Movies

replaced call per-item by 1 single call to Kodi api
This commit is contained in:
Marcel van der Veldt 2015-03-19 10:06:05 +01:00
parent 43b8cd781d
commit 5ec6afaf99

View file

@ -541,13 +541,17 @@ class LibrarySync():
viewCurrent = 1 viewCurrent = 1
for view in views: for view in views:
allMB3Movies = ReadEmbyDB().getMovies(view.get('id'),False) allMB3Movies = ReadEmbyDB().getMovies(view.get('id'),False)
allKodiMovies = ReadKodiDB().getKodiMovies(False)
if(self.ShouldStop()): if(self.ShouldStop()):
return True return True
if(allMB3Movies == None): if(allMB3Movies == None):
return False return False
if(allKodiMovies == None):
return False
if(pDialog != None): if(pDialog != None):
pDialog.update(0, "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount)) pDialog.update(0, "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount))
totalCount = len(allMB3Movies) + 1 totalCount = len(allMB3Movies) + 1
@ -556,7 +560,13 @@ class LibrarySync():
for item in allMB3Movies: for item in allMB3Movies:
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)
if not item.get('IsFolder'): if not item.get('IsFolder'):
kodiItem = ReadKodiDB().getKodiMovie(item["Id"])
kodiItem = None
for kodimovie in allKodiMovies:
if item["Id"] in kodimovie["file"]:
kodiItem = kodimovie
break
userData=API().getUserData(item) userData=API().getUserData(item)
timeInfo = API().getTimeInfo(item) timeInfo = API().getTimeInfo(item)
if kodiItem != None: if kodiItem != None: