fix for playcount sync when there are no movies set up in EMBY
This commit is contained in:
parent
0a3ad1988a
commit
69580c8ccd
1 changed files with 88 additions and 91 deletions
|
@ -818,7 +818,7 @@ class LibrarySync():
|
||||||
|
|
||||||
if(WINDOW.getProperty("updatePlayCounts_Running") == "true"):
|
if(WINDOW.getProperty("updatePlayCounts_Running") == "true"):
|
||||||
utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0)
|
utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0)
|
||||||
return
|
return False
|
||||||
WINDOW.setProperty("updatePlayCounts_Running", "true")
|
WINDOW.setProperty("updatePlayCounts_Running", "true")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -851,45 +851,42 @@ class LibrarySync():
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if(allMB3Movies == None):
|
if(allMB3Movies != None and allKodiMovies != None):
|
||||||
return False
|
|
||||||
|
if(pDialog != None):
|
||||||
|
progressTitle = "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount)
|
||||||
|
pDialog.update(0, progressTitle)
|
||||||
|
totalCount = len(allMB3Movies) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
if(allKodiMovies == None):
|
for item in allMB3Movies:
|
||||||
return False
|
|
||||||
|
|
||||||
if(pDialog != None):
|
|
||||||
progressTitle = "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount)
|
|
||||||
pDialog.update(0, progressTitle)
|
|
||||||
totalCount = len(allMB3Movies) + 1
|
|
||||||
count = 1
|
|
||||||
|
|
||||||
for item in allMB3Movies:
|
|
||||||
|
|
||||||
if not item.get('IsFolder'):
|
|
||||||
kodiItem = allKodiMovies.get(item["Id"], None)
|
|
||||||
|
|
||||||
userData = API().getUserData(item)
|
if not item.get('IsFolder'):
|
||||||
timeInfo = API().getTimeInfo(item)
|
kodiItem = allKodiMovies.get(item["Id"], None)
|
||||||
|
|
||||||
if kodiItem != None:
|
userData = API().getUserData(item)
|
||||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
timeInfo = API().getTimeInfo(item)
|
||||||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
|
||||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
if kodiItem != None:
|
||||||
if kodiresume != resume:
|
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||||
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
||||||
totalPositionsUpdated += 1
|
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
if kodiresume != resume:
|
||||||
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||||
if(updated):
|
totalPositionsUpdated += 1
|
||||||
totalCountsUpdated += 1
|
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
||||||
if(self.ShouldStop(pDialog)):
|
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
||||||
return False
|
if(updated):
|
||||||
|
totalCountsUpdated += 1
|
||||||
# update progress bar
|
|
||||||
if(pDialog != None):
|
if(self.ShouldStop(pDialog)):
|
||||||
percentage = int(((float(count) / float(totalCount)) * 100))
|
return False
|
||||||
pDialog.update(percentage, progressTitle, "Updating Movie: " + str(count))
|
|
||||||
count += 1
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
|
pDialog.update(percentage, progressTitle, "Updating Movie: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
viewCurrent += 1
|
viewCurrent += 1
|
||||||
|
|
||||||
|
@ -903,63 +900,63 @@ class LibrarySync():
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if (tvshowData == None):
|
if (tvshowData != None):
|
||||||
return False
|
|
||||||
|
|
||||||
showTotal = len(tvshowData)
|
showTotal = len(tvshowData)
|
||||||
showCurrent = 1
|
showCurrent = 1
|
||||||
|
|
||||||
for item in tvshowData:
|
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
|
for item in tvshowData:
|
||||||
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
|
||||||
kodishow = allKodiTVShows.get(item["Id"],None)
|
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
|
||||||
if kodishow != None:
|
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True)
|
kodishow = allKodiTVShows.get(item["Id"],None)
|
||||||
else:
|
if kodishow != None:
|
||||||
kodiEpisodes = None
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True)
|
||||||
|
else:
|
||||||
if (episodeData != None):
|
kodiEpisodes = None
|
||||||
if(pDialog != None):
|
|
||||||
progressTitle = "Sync PlayCounts: Processing TV Show " + str(showCurrent) + " of " + str(showTotal)
|
if (episodeData != None):
|
||||||
pDialog.update(0, progressTitle)
|
|
||||||
totalCount = len(episodeData) + 1
|
|
||||||
count = 1
|
|
||||||
|
|
||||||
for episode in episodeData:
|
|
||||||
|
|
||||||
kodiItem = None
|
|
||||||
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
|
||||||
matchFound = False
|
|
||||||
if kodiEpisodes != None:
|
|
||||||
kodiItem = kodiEpisodes.get(comparestring1, None)
|
|
||||||
|
|
||||||
userData=API().getUserData(episode)
|
|
||||||
timeInfo = API().getTimeInfo(episode)
|
|
||||||
if kodiItem != None:
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
|
||||||
WINDOW.setProperty("episodeid" + str(kodiItem['episodeid']), episode.get('Name') + ";;" + episode.get('Id'))
|
|
||||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
|
||||||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
|
||||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
|
||||||
if kodiresume != resume:
|
|
||||||
WriteKodiDB().setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
|
||||||
totalPositionsUpdated += 1
|
|
||||||
|
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
|
||||||
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "episode")
|
|
||||||
if(updated):
|
|
||||||
totalCountsUpdated += 1
|
|
||||||
if(self.ShouldStop(pDialog)):
|
|
||||||
return False
|
|
||||||
|
|
||||||
# update progress bar
|
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
percentage = int(((float(count) / float(totalCount)) * 100))
|
progressTitle = "Sync PlayCounts: Processing TV Show " + str(showCurrent) + " of " + str(showTotal)
|
||||||
pDialog.update(percentage, progressTitle, "Updating Episode: " + str(count))
|
pDialog.update(0, progressTitle)
|
||||||
count += 1
|
totalCount = len(episodeData) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
for episode in episodeData:
|
||||||
|
|
||||||
|
kodiItem = None
|
||||||
|
comparestring1 = str(episode.get("ParentIndexNumber")) + "-" + str(episode.get("IndexNumber"))
|
||||||
|
matchFound = False
|
||||||
|
if kodiEpisodes != None:
|
||||||
|
kodiItem = kodiEpisodes.get(comparestring1, None)
|
||||||
|
|
||||||
|
userData=API().getUserData(episode)
|
||||||
|
timeInfo = API().getTimeInfo(episode)
|
||||||
|
if kodiItem != None:
|
||||||
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
|
WINDOW.setProperty("episodeid" + str(kodiItem['episodeid']), episode.get('Name') + ";;" + episode.get('Id'))
|
||||||
|
kodiresume = int(round(kodiItem['resume'].get("position")))
|
||||||
|
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
||||||
|
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
||||||
|
if kodiresume != resume:
|
||||||
|
WriteKodiDB().setKodiResumePoint(kodiItem['episodeid'],resume,total,"episode")
|
||||||
|
totalPositionsUpdated += 1
|
||||||
|
|
||||||
|
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
||||||
|
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "episode")
|
||||||
|
if(updated):
|
||||||
|
totalCountsUpdated += 1
|
||||||
|
|
||||||
|
if(self.ShouldStop(pDialog)):
|
||||||
|
return False
|
||||||
|
|
||||||
showCurrent += 1
|
# update progress bar
|
||||||
|
if(pDialog != None):
|
||||||
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
|
pDialog.update(percentage, progressTitle, "Updating Episode: " + str(count))
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
showCurrent += 1
|
||||||
|
|
||||||
if(playCountSyncFirstRun != "true"):
|
if(playCountSyncFirstRun != "true"):
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
|
Loading…
Reference in a new issue