mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Fix for manually marked as watched/unwatched
The videolibrary.onupdate triggers 3 times. This prevents from sending more than one mark watched/unwatched to Emby API
This commit is contained in:
parent
5f486468ba
commit
fc05e83d90
1 changed files with 17 additions and 2 deletions
|
@ -17,6 +17,9 @@ from DownloadUtils import DownloadUtils
|
||||||
from PlaybackUtils import PlaybackUtils
|
from PlaybackUtils import PlaybackUtils
|
||||||
|
|
||||||
class Kodi_Monitor(xbmc.Monitor):
|
class Kodi_Monitor(xbmc.Monitor):
|
||||||
|
|
||||||
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
xbmc.Monitor.__init__(self)
|
xbmc.Monitor.__init__(self)
|
||||||
|
|
||||||
|
@ -26,7 +29,8 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
#this library monitor is used to detect a watchedstate change by the user through the library
|
#this library monitor is used to detect a watchedstate change by the user through the library
|
||||||
#as well as detect when a library item has been deleted to pass the delete to the Emby server
|
#as well as detect when a library item has been deleted to pass the delete to the Emby server
|
||||||
def onNotification (self,sender,method,data):
|
def onNotification (self,sender,method,data):
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
|
||||||
|
WINDOW = self.WINDOW
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
|
|
||||||
if method == "VideoLibrary.OnUpdate":
|
if method == "VideoLibrary.OnUpdate":
|
||||||
|
@ -37,16 +41,27 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
playcount = jsondata.get("playcount")
|
playcount = jsondata.get("playcount")
|
||||||
item = jsondata.get("item").get("id")
|
item = jsondata.get("item").get("id")
|
||||||
type = jsondata.get("item").get("type")
|
type = jsondata.get("item").get("type")
|
||||||
if playcount != None:
|
prop = WINDOW.getProperty('Played%s%s' % (type,item))
|
||||||
|
|
||||||
|
if (playcount != None) and (prop != "true"):
|
||||||
|
WINDOW.setProperty("Played%s%s" % (type,item), "true")
|
||||||
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
|
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
|
||||||
WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)
|
WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)
|
||||||
|
|
||||||
|
self.clearProperty(type,item)
|
||||||
|
|
||||||
if method == "System.OnWake":
|
if method == "System.OnWake":
|
||||||
xbmc.sleep(10000) #Allow network to wake up
|
xbmc.sleep(10000) #Allow network to wake up
|
||||||
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Started)",1)
|
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Started)",1)
|
||||||
libSync = LibrarySync().FullLibrarySync()
|
libSync = LibrarySync().FullLibrarySync()
|
||||||
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Finished) " + str(libSync),1)
|
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Finished) " + str(libSync),1)
|
||||||
|
|
||||||
|
def clearProperty(self,type,id):
|
||||||
|
# The sleep is necessary since VideoLibrary.OnUpdate
|
||||||
|
# triggers 3 times in a row.
|
||||||
|
xbmc.sleep(100)
|
||||||
|
self.WINDOW.clearProperty("Played%s%s" % (type,id))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue