Kodi Community Forum

Full Version: Kodi start to desync watch mark, why?!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm having problem with Kodi desyncing watch mark (because of Cache? or other magical problem).

Im using this simple code while drawing ListItem to determinate if video should be marked as watched or not:
Code:
if int(video.get("view", '0')) > 0:
    details['playcount'] = 1
    details['overlay'] = 5
    details['lastplayed'] = '2010-10-10 11:00:00'  # I even put this because i was thinking kodi want to know when it was watched
else:
    details['playcount'] = 0
    details['overlay'] = 4

And use that info this way:

Code:
liz = xbmcgui.ListItem(details.get('title', 'Unknown'))
liz.setInfo(type=tp, infoLabels=details)
liz.setProperty('IsPlayable', 'true')
...
liz.addContextMenuItems(context)
return xbmcplugin.addDirectoryItem(handle, gui_url, listitem=liz, isFolder=False)

When I play video or use MINE context menu (mark episode as watched) I simply push "view++" to server and refresh Container:

Code:
xbmc.executebuiltin('Container.Refresh')
xbmc.sleep(int(__addon__.getSetting('refresh_wait')))

So I would assume that Kodi once again parse new list from server, and draw it once again but now with proper watch mark. It does most of the times, but sometimes it wont mark video as watched (with overlay=5) but playcount=1 so mine context menu assume that this video is watched and replace context menu with "Mark this episode as unwatched", also server also got the information that this episode is watched, but Kodi ignore this.

From this point on the mark flag wont get change anyother way than using build in ToogleWatch which overwrite anything else - I can Mark Watch/Unwatch by my context menu, but icon wont change (server is updated but ListView in Kodi isn't).

EDIT: It looks like when file is marked as watched by kodi (using toggle) it save it somewhere (db) and no matter what I programicaly want to draw (flag) it is overwritten with saved status - which ain't cool. Solution/Bug/Workaround ?
(2017-08-06, 10:51)bigretromike Wrote: [ -> ]Hello,

I'm having problem with Kodi desyncing watch mark (because of Cache? or other magical problem).

Im using this simple code while drawing ListItem to determinate if video should be marked as watched or not:
Code:
if int(video.get("view", '0')) > 0:
    details['playcount'] = 1
    details['overlay'] = 5
    details['lastplayed'] = '2010-10-10 11:00:00'  # I even put this because i was thinking kodi want to know when it was watched
else:
    details['playcount'] = 0
    details['overlay'] = 4

And use that info this way:

Code:
liz = xbmcgui.ListItem(details.get('title', 'Unknown'))
liz.setInfo(type=tp, infoLabels=details)
liz.setProperty('IsPlayable', 'true')
...
liz.addContextMenuItems(context)
return xbmcplugin.addDirectoryItem(handle, gui_url, listitem=liz, isFolder=False)

When I play video or use MINE context menu (mark episode as watched) I simply push "view++" to server and refresh Container:

Code:
xbmc.executebuiltin('Container.Refresh')
xbmc.sleep(int(__addon__.getSetting('refresh_wait')))

So I would assume that Kodi once again parse new list from server, and draw it once again but now with proper watch mark. It does most of the times, but sometimes it wont mark video as watched (with overlay=5) but playcount=1 so mine context menu assume that this video is watched and replace context menu with "Mark this episode as unwatched", also server also got the information that this episode is watched, but Kodi ignore this.

From this point on the mark flag wont get change anyother way than using build in ToogleWatch which overwrite anything else - I can Mark Watch/Unwatch by my context menu, but icon wont change (server is updated but ListView in Kodi isn't).

EDIT: It looks like when file is marked as watched by kodi (using toggle) it save it somewhere (db) and no matter what I programicaly want to draw (flag) it is overwritten with saved status - which ain't cool. Solution/Bug/Workaround ?

Code looks fine, but you are executing it at the time of playback? or setting a standalone listitem not related to Kodis DB. ie Kodi doesn't take listitem properties like playcount, and lastplayed into consideration until after playback has stopped. In other words... if you set a listitem playcount of 4, it's likely Kodi will simply mark the content as 5 when playback is stopped....

Also you need to reference Kodis database id, Listitems are NOT a means of inputting database meta.

What you need to do is setup a service that monitors playback, when your content has ended, or stopped then trigger a json "setinfo" to correct the information.... however if my memory is correct you can only set playcount. There is no last played parameter... But I could be wrong about lastplayed, if I am please let me know Tongue

http://kodi.wiki/view/JSON-RPC_API/v6#Vi...vieDetails
http://kodi.wiki/view/JSON-RPC_API/v6#Vi...odeDetails
But I dont play any media from VideoLibrary. I execute code at listItem drawing (when I enter directory and when the playback got stoped )

Mine goal is to prevent kodi from adding rows to database when I play my files so I can programicly modify the flags which gets overwrite by kodi when file is in database.
(2017-08-09, 18:12)bigretromike Wrote: [ -> ]But I dont play any media from VideoLibrary. I execute code at listItem drawing (when I enter directory and when the playback got stoped )
Listitem manipulation will not prevent DB notation.


ie. setting a listitem playcount of 0 will only result in a playcount of 1 on stop if the media isn't part of the video library.
Sent from my SM-G935T
Then how to get id from db of file that I have played but dont have it in videolibrary, so I could reset counter manualy after playing it?
(2017-08-09, 20:52)bigretromike Wrote: [ -> ]Then how to get id from db of file that I have played but dont have it in videolibrary, so I could reset counter manualy after playing it?

You can't, I'm unaware of any indexing process for other vfs content... beyond basic content tracking.

I don't see how this meta could impact you... nothing takes advantage of this meta since it's not available through rpc.

Could you elaborate on why you don't want the DB to make these references?
Simples as this:
- Im using backend with all needed information playcount/mediainfo etc.
- I use the data I have about media/playcount and build Folder with Files that I can watch and Interact with file (like reset mark/mark as watched/play/etc)
- All is fine until I PLAY the file
- If I play the file KODI save path + file inside DB, generete StreamDetails and after redrawing ListItem even if I send same data Kodi use data from DB and overwrite data for THAT file that Kodi played.
- So in the end kodi overwrite data in ListItem acording to data that he have inside db for that file.