Second attempt at fixing playcount situation
This should also reflect the actual Emby playcount. The websocket didn't echo, but what I did is kill the echo caused by the video library update after userdata change happens.
This commit is contained in:
parent
2aefab1545
commit
ddb7ec4bbd
6 changed files with 33 additions and 33 deletions
|
@ -158,7 +158,7 @@ class API():
|
||||||
else:
|
else:
|
||||||
favorite=False
|
favorite=False
|
||||||
if(userData.get("Played") == True):
|
if(userData.get("Played") == True):
|
||||||
playcount="1"
|
playcount= userData.get('PlayCount')
|
||||||
else:
|
else:
|
||||||
playcount="0"
|
playcount="0"
|
||||||
if userData.get('UnplayedItemCount') != None:
|
if userData.get('UnplayedItemCount') != None:
|
||||||
|
|
|
@ -34,22 +34,24 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
|
|
||||||
if method == "VideoLibrary.OnUpdate":
|
if method == "VideoLibrary.OnUpdate":
|
||||||
jsondata = json.loads(data)
|
if WINDOW.getProperty('prevent_libraryUpdate') != "true":
|
||||||
if jsondata != None:
|
jsondata = json.loads(data)
|
||||||
|
if jsondata != None:
|
||||||
|
|
||||||
playcount = None
|
playcount = None
|
||||||
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")
|
||||||
prop = WINDOW.getProperty('Played%s%s' % (type,item))
|
prop = WINDOW.getProperty('Played%s%s' % (type,item))
|
||||||
processWatched = WINDOW.getProperty('played_skipWatched')
|
processWatched = WINDOW.getProperty('played_skipWatched')
|
||||||
|
|
||||||
if (playcount != None) and (prop != "true") and (processWatched != "true"):
|
if (playcount != None) and (prop != "true") and (processWatched != "true"):
|
||||||
WINDOW.setProperty("Played%s%s" % (type,item), "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)
|
||||||
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
|
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
|
||||||
|
|
||||||
self.clearProperty(type,item)
|
self.clearProperty(type,item)
|
||||||
|
WINDOW.clearProperty('prevent_libraryUpdate')
|
||||||
|
|
||||||
if method == "System.OnWake":
|
if method == "System.OnWake":
|
||||||
xbmc.sleep(10000) #Allow network to wake up
|
xbmc.sleep(10000) #Allow network to wake up
|
||||||
|
|
|
@ -101,6 +101,9 @@ class PlaybackUtils():
|
||||||
|
|
||||||
#show the additional resume dialog if launched from a widget
|
#show the additional resume dialog if launched from a widget
|
||||||
if xbmc.getCondVisibility("Window.IsActive(home)"):
|
if xbmc.getCondVisibility("Window.IsActive(home)"):
|
||||||
|
if userData.get("PlaybackPositionTicks") != 0:
|
||||||
|
reasonableTicks = int(userData.get("PlaybackPositionTicks")) / 1000
|
||||||
|
seekTime = reasonableTicks / 10000
|
||||||
if seekTime != 0:
|
if seekTime != 0:
|
||||||
displayTime = str(datetime.timedelta(seconds=seekTime))
|
displayTime = str(datetime.timedelta(seconds=seekTime))
|
||||||
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
||||||
|
|
|
@ -296,7 +296,7 @@ class Player( xbmc.Player ):
|
||||||
'SubtitleStreamIndex': subtitleindex,
|
'SubtitleStreamIndex': subtitleindex,
|
||||||
'playmethod': playMethod,
|
'playmethod': playMethod,
|
||||||
'Type': itemType,
|
'Type': itemType,
|
||||||
'PositionTicks': int(seekTime)
|
'currentPosition': int(seekTime)
|
||||||
}
|
}
|
||||||
self.played_information[currentFile] = data
|
self.played_information[currentFile] = data
|
||||||
self.logMsg("ADDING_FILE: %s" % self.played_information, 1)
|
self.logMsg("ADDING_FILE: %s" % self.played_information, 1)
|
||||||
|
|
|
@ -32,6 +32,8 @@ class WebSocketThread(threading.Thread):
|
||||||
doUtils = DownloadUtils()
|
doUtils = DownloadUtils()
|
||||||
clientInfo = ClientInformation()
|
clientInfo = ClientInformation()
|
||||||
KodiMonitor = KodiMonitor.Kodi_Monitor()
|
KodiMonitor = KodiMonitor.Kodi_Monitor()
|
||||||
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
addonName = clientInfo.getAddonName()
|
addonName = clientInfo.getAddonName()
|
||||||
|
|
||||||
client = None
|
client = None
|
||||||
|
@ -101,13 +103,8 @@ class WebSocketThread(threading.Thread):
|
||||||
messageType = result.get("MessageType")
|
messageType = result.get("MessageType")
|
||||||
data = result.get("Data")
|
data = result.get("Data")
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
playedItemId = WINDOW.getProperty('played_itemId')
|
|
||||||
|
|
||||||
if (playedItemId != '') and (playedItemId in message):
|
if(messageType != None and messageType == "Play" and data != None):
|
||||||
# Prevent feedback for watched
|
|
||||||
WINDOW.clearProperty('played_itemId')
|
|
||||||
|
|
||||||
elif(messageType != None and messageType == "Play" and data != None):
|
|
||||||
itemIds = data.get("ItemIds")
|
itemIds = data.get("ItemIds")
|
||||||
playCommand = data.get("PlayCommand")
|
playCommand = data.get("PlayCommand")
|
||||||
|
|
||||||
|
@ -289,6 +286,7 @@ class WebSocketThread(threading.Thread):
|
||||||
LibrarySync().IncrementalSync(itemsToUpdate)
|
LibrarySync().IncrementalSync(itemsToUpdate)
|
||||||
|
|
||||||
def user_data_update(self, userDataList):
|
def user_data_update(self, userDataList):
|
||||||
|
self.WINDOW.setProperty('prevent_libraryUpdate', "true")
|
||||||
itemsToUpdate = list()
|
itemsToUpdate = list()
|
||||||
for userData in userDataList:
|
for userData in userDataList:
|
||||||
itemId = userData.get("ItemId")
|
itemId = userData.get("ItemId")
|
||||||
|
|
|
@ -117,9 +117,8 @@ class WriteKodiVideoDB():
|
||||||
else:
|
else:
|
||||||
dateadded = None
|
dateadded = None
|
||||||
|
|
||||||
playcount = 0
|
if userData.get("PlayCount") != "0":
|
||||||
if userData.get("PlayCount") == "1":
|
playcount = int(userData.get('PlayCount'))
|
||||||
playcount = 1
|
|
||||||
else:
|
else:
|
||||||
playcount = None #playcount must be set to NULL in the db
|
playcount = None #playcount must be set to NULL in the db
|
||||||
|
|
||||||
|
@ -267,9 +266,8 @@ class WriteKodiVideoDB():
|
||||||
else:
|
else:
|
||||||
dateadded = None
|
dateadded = None
|
||||||
|
|
||||||
playcount = 0
|
if userData.get("PlayCount") != "0":
|
||||||
if userData.get("PlayCount") == "1":
|
playcount = int(userData.get('PlayCount'))
|
||||||
playcount = 1
|
|
||||||
else:
|
else:
|
||||||
playcount = None #playcount must be set to NULL in the db
|
playcount = None #playcount must be set to NULL in the db
|
||||||
|
|
||||||
|
@ -550,9 +548,8 @@ class WriteKodiVideoDB():
|
||||||
else:
|
else:
|
||||||
lastplayed = None
|
lastplayed = None
|
||||||
|
|
||||||
playcount = None
|
if userData.get("PlayCount") != "0":
|
||||||
if userData.get("PlayCount") == "1":
|
playcount = int(userData.get('PlayCount'))
|
||||||
playcount = 1
|
|
||||||
else:
|
else:
|
||||||
playcount = None #playcount must be set to NULL in the db
|
playcount = None #playcount must be set to NULL in the db
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue