Fix updatePlayCountFromKodi to use getEmbyIdByKodiId and done do a playcount sync if one is already running
This commit is contained in:
parent
959659c1c9
commit
6dbdb88fa7
2 changed files with 10 additions and 27 deletions
|
@ -783,6 +783,11 @@ class LibrarySync():
|
||||||
processMovies = True
|
processMovies = True
|
||||||
processTvShows = True
|
processTvShows = True
|
||||||
|
|
||||||
|
if(WINDOW.getProperty("updatePlayCounts_Running") == "true"):
|
||||||
|
utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0)
|
||||||
|
return
|
||||||
|
WINDOW.setProperty("updatePlayCounts_Running", "true")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playCountSyncIndication = addon.getSetting("playCountSyncIndication")
|
playCountSyncIndication = addon.getSetting("playCountSyncIndication")
|
||||||
playCountSyncFirstRun = addon.getSetting("SyncFirstCountsRunDone")
|
playCountSyncFirstRun = addon.getSetting("SyncFirstCountsRunDone")
|
||||||
|
@ -841,7 +846,7 @@ class LibrarySync():
|
||||||
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
WriteKodiDB().setKodiResumePoint(kodiItem['movieid'],resume,total,"movie")
|
||||||
totalPositionsUpdated += 1
|
totalPositionsUpdated += 1
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")), "movie")
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie")
|
||||||
if(updated):
|
if(updated):
|
||||||
totalCountsUpdated += 1
|
totalCountsUpdated += 1
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
|
@ -904,7 +909,7 @@ class LibrarySync():
|
||||||
totalPositionsUpdated += 1
|
totalPositionsUpdated += 1
|
||||||
|
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
updated = WriteKodiDB().updateProperty(kodiItem,"playcount",int(userData.get("PlayCount")),"episode")
|
||||||
updated = WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "episode")
|
updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "episode")
|
||||||
if(updated):
|
if(updated):
|
||||||
totalCountsUpdated += 1
|
totalCountsUpdated += 1
|
||||||
if(self.ShouldStop(pDialog)):
|
if(self.ShouldStop(pDialog)):
|
||||||
|
@ -943,6 +948,7 @@ class LibrarySync():
|
||||||
xbmc.executebuiltin("XBMC.Notification(PlayCount Sync: " + notificationString + ",)")
|
xbmc.executebuiltin("XBMC.Notification(PlayCount Sync: " + notificationString + ",)")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
WINDOW.setProperty("updatePlayCounts_Running", "false")
|
||||||
if(pDialog != None):
|
if(pDialog != None):
|
||||||
pDialog.close()
|
pDialog.close()
|
||||||
|
|
||||||
|
|
|
@ -34,32 +34,9 @@ class WriteKodiDB():
|
||||||
def updatePlayCountFromKodi(self, id, type, playcount=0):
|
def updatePlayCountFromKodi(self, id, type, playcount=0):
|
||||||
#when user marks item watched from kodi interface update this in MB3
|
#when user marks item watched from kodi interface update this in MB3
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
xbmc.log("WriteKodiDB -> updatePlayCountFromKodi Called")
|
utils.logMsg("MB3 Sync", "updatePlayCountFromKodi Called")
|
||||||
|
|
||||||
mb3Id = None
|
mb3Id = ReadKodiDB().getEmbyIdByKodiId(id, type)
|
||||||
if(type == "movie"):
|
|
||||||
mb3Id = None
|
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": { "movieid": ' + str(id) + ', "properties" : ["playcount", "file"] }, "id": "1"}')
|
|
||||||
if json_response != None:
|
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
|
||||||
if(jsonobject.has_key('result')):
|
|
||||||
result = jsonobject['result']
|
|
||||||
if(result.has_key('moviedetails')):
|
|
||||||
moviedetails = result['moviedetails']
|
|
||||||
filename = moviedetails.get("file").rpartition('\\')[2]
|
|
||||||
mb3Id = filename.replace(".strm","")
|
|
||||||
|
|
||||||
elif(type == "episode"):
|
|
||||||
mb3Id = None
|
|
||||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodeDetails", "params": { "episodeid": ' + str(id) + ', "properties" : ["playcount", "file"] }, "id": "1"}')
|
|
||||||
if json_response != None:
|
|
||||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
|
||||||
if(jsonobject.has_key('result')):
|
|
||||||
result = jsonobject['result']
|
|
||||||
if(result.has_key('episodedetails')):
|
|
||||||
episodedetails = result['episodedetails']
|
|
||||||
filename = episodedetails.get("file").rpartition('\\')[2]
|
|
||||||
mb3Id = filename[-38:-6]
|
|
||||||
|
|
||||||
if(mb3Id != None):
|
if(mb3Id != None):
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
|
Loading…
Reference in a new issue