Kodi Community Forum

Full Version: How to set watched status via python code?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I am working on the SageTV addon which essentially displays directories of SageTV recordings and allows you to watch shows, etc, that exist within the SageTV server.

One feature I can't figure out is how to indicate to XBMC which shows have been watched. I can pull the watched status from the SageTV server with no issues, but I don't know how to tell XBMC that a show has been watched.

I see there is a PercentPlayed InfoLabel, but that doesn't seem to work.

http://wiki.xbmc.org/index.php?title=InfoLabels

Is there a way I can set the XBMC watched status via python code? Is there an InfoLabel or something else I can use? Thoughts?
The info label to set is "overlay" and I believe setting it to 6 marks it as watched. Check out script.module.metahandlers in the official repo for easy meta data and watched status handling
On Frodo you can use JSON-RPC
(2012-09-20, 07:13)Martijn Wrote: [ -> ]On Frodo you can use JSON-RPC

XBMC's JSON RPC is new to me... can you point me to an example call or some reference material? I am using JSON RPC with Sage to get the metadata so I'm familiar with the concept, but not sure how to use XBMC's or what the pre-reqs might be other than Frodo. It'd be great to know what API call I should use and how that might work. Appreciate the help.
(2012-09-20, 06:26)Bstrdsmkr Wrote: [ -> ]The info label to set is "overlay" and I believe setting it to 6 marks it as watched. Check out script.module.metahandlers in the official repo for easy meta data and watched status handling

I'd rather stay clear of SQL and use something more native like JSON. Looking forward to Martjin's guidance.
There's no SQL there, just the infolabel: http://mirrors.xbmc.org/docs/python-docs...em-setInfo

By way of example:
Code:
def addLink(name,url,iconimage):
        ok=True
        pl=xbmc.PlayList(1)
        pl.clear()
        liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
        liz.setInfo( type="Video", infoLabels={ "Title": name, "overlay":"6"})
        xbmc.PlayList(1).add(url, liz)
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=False)
        return ok
The script.module.metahandlers looked like it was all SQL, but I like the InfoLabel approach. One question though... does this just overlay an image, or can you also use the filter on the left panel to show and hide watched?

PS... just tried the overlay of 6 like you have and it does not show a watched icon (I'm using Frodo alpha from August).
Ahh I see what you meant, metahandlers uses it's own database to avoid monkeying with xbmc's database, you wouldn't need to use SQL directly to implement it though.

What skin are you using? Works for me in Confluence/Eden final. Once set, it will also be taken into account for sorting and Hide Watched (although it won't affect playcount)

Sorry, that should actually be 7, not 6 and an int, not a str. Relevant values can be found in lines 48-56 of https://github.com/xbmc/xbmc/blob/master...ListItem.h (starting at 0)
(2012-09-20, 21:18)Bstrdsmkr Wrote: [ -> ]Ahh I see what you meant, metahandlers uses it's own database to avoid monkeying with xbmc's database, you wouldn't need to use SQL directly to implement it though.

What skin are you using? Works for me in Confluence/Eden final. Once set, it will also be taken into account for sorting and Hide Watched (although it won't affect playcount)

Sorry, that should actually be 7, not 6 and an int, not a str. Relevant values can be found in lines 48-56 of https://github.com/xbmc/xbmc/blob/master...ListItem.h (starting at 0)

Yeah this is more along the lines of what I'm looking for but doesn't seem to work in the Frodo August alpha build I am running which I'm using the default Confluence skin with. I set the overlay to int of 7 for watched and 6 for unwatched but it doesn't seem to set anything. And the hide watched filter doesn't work. Any other suggestions? I definitely am looking forward to hearing how this could be done with Frodo's JSON RPC but not sure how to go about that.
UPDATE: I think I figured it out! You need to set two infolabels to indicate that something has been watched.

InfoLabels to set for Watched
"overlay": 7
"watched": True

InfoLabels to set for Unwatched
"overlay": 6
"watched": False
Odd, wonder if that's something new in Frodo. Glad you got it going though!
(2012-09-21, 03:21)Bstrdsmkr Wrote: [ -> ]Odd, wonder if that's something new in Frodo. Glad you got it going though!

Thanks again for your help. On a similar note, do you know how to tell the ListItem that it has already been played before and the resume point is say 25% of the way through the file such that when I click Play, instead of starting from the beginning, it prompts me to resume from a specific point?

I tried setting the PercentPlayed InfoLabel but that didn't appear to do anything (clicking Play always starts from the beginning)
Unfortunately to my knowledge you can't without digging around in Xbmc's database. I keep a separate database in 1channel and popup a yes/no dialog when playback starts if I've saved a bookmark. Mscreations even broke that out into a script module: https://github.com/mscreations/mscreatio...backengine
I did some more digging and looks like devs have added a new ListItem.IsResumable flag as part of Frodo. Unforunately, that doesn't do anything when I use it. I would have loved it if I could set a similar overlay (like OverlayPartiallyWatched) which would show the partially watched icon like would happen if I truly partially watched it, and then XBMC prompts me to resume or play from beginning. I would have to imagine there's a way, but I'm sure the XBMC devs have bigger fish to fry. Some day I guess.
Strictly speaking, It does track it just like local content. The problem is that Xbmc's tracking is based on the playable path, which with an addon is dynamic =/
Pages: 1 2 3