How to set watched status via python code?
#16
Hi,

I work on my personal plugin to parse flash video from web site and then put on my Rasppbery PI with raspbmc RC5 and XBMC 12.0-Alpha7. But now I try to make auto watching in this plugin, like pressed button "w" on the keyboard. Read previous posts in this forum and understand how to put "watched" in the setInfo, but I'm not understand how to check this values and after really play my flash video to mark as "watched", because if I not check this value "watched" or "playcount" all of my videos will marked.

def addActionListItem(item_params = {}, size = 0):
item = item_params.get
folder = False
#modify icon and thumbnail display
icon = "DefaultFolder.png"

thumbnail = item("thumbnail")
if (item("thumbnail", "DefaultFolder.png").find("http://") == -1):
thumbnail = "DefaultFolder.png"

listitem = xbmcgui.ListItem(item("Title"), iconImage=icon, thumbnailImage=thumbnail)
listitem.setInfo(type = 'video', infoLabels = {'Title': item("Title"), "playcount": 1, "watched": True})

url = buildItemUrl(item_params, '%s?' % sys.argv[0])

xbmcplugin.addDirectoryItem(handle, url=url, listitem=listitem, isFolder=folder, totalItems=size)
Reply
#17
If XBMC is handling the watched status (i.e. all you do is feed it URLs) then it'll work without you having to do anything.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#18
Thanks for your answer jmarshall,

That's it's good news for watched status, but what you mean with "feed it URLs". Please show me what is need I do.

This is my funtion for Url:

def buildItemUrl(item_params = {}, url = ""):
for k, v in item_params.items():
if (k != "Title" and k != 'thumbnail'):
url += k + "=" + urllib.quote_plus(v) + "&"
return url

Dump "url" from addActionListItem is follow:

plugin://plugin.video.vbox7/?name=%D0%90%D0%BC%D0%B5%D1%80%D0%B8%D0%BA%D0%B0%D0%BD%D1%81%D0%BA%D0%B8+%D0%B4%D1%80%D0%B0%D0%BA%D0%BE%D0%BD+2%D1%8504+%28%D0%B1%D0%B3+%D0%B0%D1%83%D0%B4%D0%B8%D0%BE%29+American+dragon+&vid=f237a208&act=play&page=2&
Reply
#19
Are you setting it as a playable item, or do you act on the "act=play" URL option and start playback yourself using xbmc.player.PlayItem() ?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#20
Second one, check for the "act=play" see following:

elif get('act') == 'play':
PlayVid(urllib.unquote_plus(get('vid')), urllib.unquote_plus(get('name')))

def PlayVid(vid, name = ""):
print "playing " + vid
result = getPage('http://vbox7.com/etc/ext.do?key=' + vid)
match = re.compile('flv_addr=(.+?)&jpg_addr=(.+?)&').findall(result)
if (len(match) == 1 and len(match[0]) == 2):
print "flv: " + match[0][0]
print "thumb: " + match[0][1]
item = xbmcgui.ListItem(label = name, thumbnailImage = 'http://' + match[0][1])
item.setInfo(type = 'video', infoLabels = {'Title': name})
print "playing: " + "http://" + match[0][0]
#xbmc.executebuiltin("PlayMedia(" + "http://" + match[0][0] + ")")
xbmc.Player().play("http://" + match[0][0], item)
return True
else:
showMessage('Error', 'Video not found')
return False
Reply
#21
Then there's nothing to be done. You should strongly consider dropping that and using setResolvedUrl() et. al. instead.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#22
OK, I'll do that, but where is need url to be same...in the "addActionListItem" and in "PlayVid", after that watched status will handled from XBMC?
Reply
#23
(2012-09-21, 03:04)LehighBri Wrote: 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

I've taken a quick look around and couldn't find any documentation for this change.. is there any?

Just would like to update the metahandlers script appropriately for Frodo
Reply
#24
(2012-11-05, 17:22)Eldorado Wrote:
(2012-09-21, 03:04)LehighBri Wrote: 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

I've taken a quick look around and couldn't find any documentation for this change.. is there any?

Just would like to update the metahandlers script appropriately for Frodo

I don't there's any documentation per se, but in post #8 in this thread, it gives a list of the various overlays that can be set:

https://github.com/xbmc/xbmc/blob/master...ListItem.h

This is the relevant line:
Code:
enum GUIIconOverlay { ICON_OVERLAY_NONE = 0,
                        ICON_OVERLAY_RAR,
                        ICON_OVERLAY_ZIP,
                        ICON_OVERLAY_LOCKED,
                        ICON_OVERLAY_HAS_TRAINER,
                        ICON_OVERLAY_TRAINED,
                        ICON_OVERLAY_UNWATCHED,
                        ICON_OVERLAY_WATCHED,
                        ICON_OVERLAY_HD};

(2012-09-21, 21:11)LehighBri Wrote: 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.

jmarshall - any thoughts on my previous post here re: indicating that a ListItem was partially watched and thus can be resumed?
Reply
#25
(2012-11-05, 17:28)LehighBri Wrote:
(2012-11-05, 17:22)Eldorado Wrote:
(2012-09-21, 03:04)LehighBri Wrote: 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

I've taken a quick look around and couldn't find any documentation for this change.. is there any?

Just would like to update the metahandlers script appropriately for Frodo

I don't there's any documentation per se, but in post #8 in this thread, it gives a list of the various overlays that can be set:

https://github.com/xbmc/xbmc/blob/master...ListItem.h

This is the relevant line:
Code:
enum GUIIconOverlay { ICON_OVERLAY_NONE = 0,
                        ICON_OVERLAY_RAR,
                        ICON_OVERLAY_ZIP,
                        ICON_OVERLAY_LOCKED,
                        ICON_OVERLAY_HAS_TRAINER,
                        ICON_OVERLAY_TRAINED,
                        ICON_OVERLAY_UNWATCHED,
                        ICON_OVERLAY_WATCHED,
                        ICON_OVERLAY_HD};


Thanks, that code still just looks like it's using values 6 and 7 for unwatched/watched status

I've added code in metahandlers for the 'watched' and 'unwatched' labels and is working as you have said.. just wondering how you came across the info to set those new labels?
Reply
#26
You have 2 choices:

1. Supply the resume point from your plugin. This overrides XBMC's resume point. You do this by setting totaltime and starttime properties.
2. Let XBMC handle it all.

The second can only be done using playable plugin:// items (i.e. items that XBMC plays back by feeding the plugin:// URL back to your script and you respond by calling setResolvedUrl).
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#27
(2012-11-06, 01:59)jmarshall Wrote: 1. Supply the resume point from your plugin. This overrides XBMC's resume point. You do this by setting totaltime and starttime properties.

Is it possible to set totaltime > current for growing files? Also startoffset still seems to work for resuming will that be removed in Frodo?

Martin
Reply
#28
I may have gotten the property wrong - check the code to make sure.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#29
Thank you jmarshall,

I solve my problem and rewrite very easy my plugin to use setResolvedUrl() and XBMC to handle my watch/unwatch status and resuming time:

1) Add in my function addActionListItem following:
Code:
listitem.setProperty('IsPlayable', 'true');


Code:
def addActionListItem(item_params = {}, size = 0):
        item = item_params.get
        folder = False

        icon = "DefaultFolder.png"

        thumbnail = item("thumbnail")
        if (item("thumbnail", "DefaultFolder.png").find("http://") == -1):
                thumbnail = "DefaultFolder.png"

        listitem = xbmcgui.ListItem(item("Title"), iconImage=icon, thumbnailImage=thumbnail)
        listitem.setInfo(type = 'video', infoLabels = {'Title': item("Title")})

        listitem.setProperty('IsPlayable', 'true');
        url = buildItemUrl(item_params, '%s?' % sys.argv[0])

        xbmcplugin.addDirectoryItem(handle, url=url, listitem=listitem, isFolder=folder, totalItems=size)

2) And second one is to change my PlayVid function to use setResolvedUrl():

Code:
def PlayVid(vid, name = ""):
    print "playing " + vid
    result = getPage('http://vbox7.com/etc/ext.do?key=' + vid)
    match = re.compile('flv_addr=(.+?)&jpg_addr=(.+?)&').findall(result)
    if (len(match) == 1 and len(match[0]) == 2):
        print "flv: " + match[0][0]
        print "thumb: " + match[0][1]
        item = xbmcgui.ListItem(label = name, thumbnailImage = 'http://' + match[0][1], path= 'http://' + match[0][0])#Here modify my ListItem and put in additional only "path= 'http://' + match[0][0]" in the previous one
        item.setInfo(type = 'video', infoLabels = {'Title': name})
        print "playing: " + "http://" + match[0][0]
        #xbmc.Player().play("http://" + match[0][0], item)#This is my old method for playing video
        xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
        return True
    else:
        showMessage('Error', 'Video not found')
        return False
Reply
#30
Perfect - thanks for the code snippet - it'll be helpful when others search Smile
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply

Logout Mark Read Team Forum Stats Members Help
How to set watched status via python code?0