mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
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(allKodiMovies == None):
|
if(pDialog != None):
|
||||||
return False
|
progressTitle = "Sync PlayCounts: Processing " + view.get('title') + " " + str(viewCurrent) + " of " + str(viewCount)
|
||||||
|
pDialog.update(0, progressTitle)
|
||||||
|
totalCount = len(allMB3Movies) + 1
|
||||||
|
count = 1
|
||||||
|
|
||||||
if(pDialog != None):
|
for item in allMB3Movies:
|
||||||
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)
|
||||||
|
|
||||||
if not item.get('IsFolder'):
|
userData = API().getUserData(item)
|
||||||
kodiItem = allKodiMovies.get(item["Id"], None)
|
timeInfo = API().getTimeInfo(item)
|
||||||
|
|
||||||
userData = API().getUserData(item)
|
if kodiItem != None:
|
||||||
timeInfo = API().getTimeInfo(item)
|
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['movieid'],resume,total,"movie")
|
||||||
|
totalPositionsUpdated += 1
|
||||||
|
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
||||||
|
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
||||||
|
if(updated):
|
||||||
|
totalCountsUpdated += 1
|
||||||
|
|
||||||
if kodiItem != None:
|
if(self.ShouldStop(pDialog)):
|
||||||
kodiresume = int(round(kodiItem['resume'].get("position")))
|
return False
|
||||||
resume = int(round(float(timeInfo.get("ResumeTime"))))*60
|
|
||||||
total = int(round(float(timeInfo.get("TotalTime"))))*60
|
|
||||||
if kodiresume != resume:
|
|
||||||
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
|
||||||
totalPositionsUpdated += 1
|
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
|
||||||
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
|
||||||
if(updated):
|
|
||||||
totalCountsUpdated += 1
|
|
||||||
if(self.ShouldStop(pDialog)):
|
|
||||||
return False
|
|
||||||
|
|
||||||
# update progress bar
|
# update progress bar
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
percentage = int(((float(count) / float(totalCount)) * 100))
|
percentage = int(((float(count) / float(totalCount)) * 100))
|
||||||
pDialog.update(percentage, progressTitle, "Updating Movie: " + str(count))
|
pDialog.update(percentage, progressTitle, "Updating Movie: " + str(count))
|
||||||
count += 1
|
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:
|
for item in tvshowData:
|
||||||
|
|
||||||
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
|
episodeData = ReadEmbyDB().getEpisodes(item["Id"], False)
|
||||||
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
allKodiTVShows = ReadKodiDB().getKodiTvShows(False)
|
||||||
kodishow = allKodiTVShows.get(item["Id"],None)
|
kodishow = allKodiTVShows.get(item["Id"],None)
|
||||||
if kodishow != None:
|
if kodishow != None:
|
||||||
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True)
|
kodiEpisodes = ReadKodiDB().getKodiEpisodes(kodishow["tvshowid"],False,True)
|
||||||
else:
|
else:
|
||||||
kodiEpisodes = None
|
kodiEpisodes = None
|
||||||
|
|
||||||
if (episodeData != None):
|
if (episodeData != None):
|
||||||
if(pDialog != None):
|
|
||||||
progressTitle = "Sync PlayCounts: Processing TV Show " + str(showCurrent) + " of " + str(showTotal)
|
|
||||||
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
|
||||||
|
|
||||||
showCurrent += 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):
|
||||||
|
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