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:
angelblue05 2015-05-17 00:37:53 -05:00
parent 2aefab1545
commit ddb7ec4bbd
6 changed files with 33 additions and 33 deletions

View File

@ -158,7 +158,7 @@ class API():
else:
favorite=False
if(userData.get("Played") == True):
playcount="1"
playcount= userData.get('PlayCount')
else:
playcount="0"
if userData.get('UnplayedItemCount') != None:

View File

@ -34,22 +34,24 @@ class Kodi_Monitor(xbmc.Monitor):
downloadUtils = DownloadUtils()
if method == "VideoLibrary.OnUpdate":
jsondata = json.loads(data)
if jsondata != None:
if WINDOW.getProperty('prevent_libraryUpdate') != "true":
jsondata = json.loads(data)
if jsondata != None:
playcount = None
playcount = jsondata.get("playcount")
item = jsondata.get("item").get("id")
type = jsondata.get("item").get("type")
prop = WINDOW.getProperty('Played%s%s' % (type,item))
processWatched = WINDOW.getProperty('played_skipWatched')
playcount = None
playcount = jsondata.get("playcount")
item = jsondata.get("item").get("id")
type = jsondata.get("item").get("type")
prop = WINDOW.getProperty('Played%s%s' % (type,item))
processWatched = WINDOW.getProperty('played_skipWatched')
if (playcount != None) and (prop != "true") and (processWatched != "true"):
WINDOW.setProperty("Played%s%s" % (type,item), "true")
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
if (playcount != None) and (prop != "true") and (processWatched != "true"):
WINDOW.setProperty("Played%s%s" % (type,item), "true")
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount)
self.clearProperty(type,item)
self.clearProperty(type,item)
WINDOW.clearProperty('prevent_libraryUpdate')
if method == "System.OnWake":
xbmc.sleep(10000) #Allow network to wake up

View File

@ -101,6 +101,9 @@ class PlaybackUtils():
#show the additional resume dialog if launched from a widget
if xbmc.getCondVisibility("Window.IsActive(home)"):
if userData.get("PlaybackPositionTicks") != 0:
reasonableTicks = int(userData.get("PlaybackPositionTicks")) / 1000
seekTime = reasonableTicks / 10000
if seekTime != 0:
displayTime = str(datetime.timedelta(seconds=seekTime))
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]

View File

@ -296,7 +296,7 @@ class Player( xbmc.Player ):
'SubtitleStreamIndex': subtitleindex,
'playmethod': playMethod,
'Type': itemType,
'PositionTicks': int(seekTime)
'currentPosition': int(seekTime)
}
self.played_information[currentFile] = data
self.logMsg("ADDING_FILE: %s" % self.played_information, 1)

View File

@ -32,6 +32,8 @@ class WebSocketThread(threading.Thread):
doUtils = DownloadUtils()
clientInfo = ClientInformation()
KodiMonitor = KodiMonitor.Kodi_Monitor()
WINDOW = xbmcgui.Window(10000)
addonName = clientInfo.getAddonName()
client = None
@ -101,13 +103,8 @@ class WebSocketThread(threading.Thread):
messageType = result.get("MessageType")
data = result.get("Data")
WINDOW = xbmcgui.Window( 10000 )
playedItemId = WINDOW.getProperty('played_itemId')
if (playedItemId != '') and (playedItemId in message):
# Prevent feedback for watched
WINDOW.clearProperty('played_itemId')
elif(messageType != None and messageType == "Play" and data != None):
if(messageType != None and messageType == "Play" and data != None):
itemIds = data.get("ItemIds")
playCommand = data.get("PlayCommand")
@ -289,6 +286,7 @@ class WebSocketThread(threading.Thread):
LibrarySync().IncrementalSync(itemsToUpdate)
def user_data_update(self, userDataList):
self.WINDOW.setProperty('prevent_libraryUpdate', "true")
itemsToUpdate = list()
for userData in userDataList:
itemId = userData.get("ItemId")

View File

@ -117,9 +117,8 @@ class WriteKodiVideoDB():
else:
dateadded = None
playcount = 0
if userData.get("PlayCount") == "1":
playcount = 1
if userData.get("PlayCount") != "0":
playcount = int(userData.get('PlayCount'))
else:
playcount = None #playcount must be set to NULL in the db
@ -267,9 +266,8 @@ class WriteKodiVideoDB():
else:
dateadded = None
playcount = 0
if userData.get("PlayCount") == "1":
playcount = 1
if userData.get("PlayCount") != "0":
playcount = int(userData.get('PlayCount'))
else:
playcount = None #playcount must be set to NULL in the db
@ -550,9 +548,8 @@ class WriteKodiVideoDB():
else:
lastplayed = None
playcount = None
if userData.get("PlayCount") == "1":
playcount = 1
if userData.get("PlayCount") != "0":
playcount = int(userData.get('PlayCount'))
else:
playcount = None #playcount must be set to NULL in the db