diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index c2f23b78..efb5e18c 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -783,6 +783,11 @@ class LibrarySync(): processMovies = True processTvShows = True + if(WINDOW.getProperty("updatePlayCounts_Running") == "true"): + utils.logMsg("Sync PlayCount", "updatePlayCounts Already Running", 0) + return + WINDOW.setProperty("updatePlayCounts_Running", "true") + try: playCountSyncIndication = addon.getSetting("playCountSyncIndication") playCountSyncFirstRun = addon.getSetting("SyncFirstCountsRunDone") @@ -841,7 +846,7 @@ class LibrarySync(): 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") + updated |= WriteKodiDB().updateProperty(kodiItem,"lastplayed",userData.get("LastPlayedDate"), "movie") if(updated): totalCountsUpdated += 1 if(self.ShouldStop(pDialog)): @@ -904,7 +909,7 @@ class LibrarySync(): totalPositionsUpdated += 1 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): totalCountsUpdated += 1 if(self.ShouldStop(pDialog)): @@ -943,6 +948,7 @@ class LibrarySync(): xbmc.executebuiltin("XBMC.Notification(PlayCount Sync: " + notificationString + ",)") finally: + WINDOW.setProperty("updatePlayCounts_Running", "false") if(pDialog != None): pDialog.close() diff --git a/resources/lib/WriteKodiDB.py b/resources/lib/WriteKodiDB.py index c3a07188..a3e4b250 100644 --- a/resources/lib/WriteKodiDB.py +++ b/resources/lib/WriteKodiDB.py @@ -34,32 +34,9 @@ class WriteKodiDB(): def updatePlayCountFromKodi(self, id, type, playcount=0): #when user marks item watched from kodi interface update this in MB3 xbmc.sleep(sleepVal) - xbmc.log("WriteKodiDB -> updatePlayCountFromKodi Called") + utils.logMsg("MB3 Sync", "updatePlayCountFromKodi Called") - mb3Id = None - 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] + mb3Id = ReadKodiDB().getEmbyIdByKodiId(id, type) if(mb3Id != None): addon = xbmcaddon.Addon(id='plugin.video.emby')