Context Menu item that creates a folder listing?
#1
We've been working on a "search similar" context menu item function for the youtube plugin..

This is supposed to allow the user to search for an existing video title (for instance to find a better version of the same video) and generate a folder listing with the results of the users search.

Every-time we trigger this function we get "invalid handle -1", is this just an impossible scenario or are we doing something wrong?

/HenrikDK
Reply
#2
a little bit more info could be useful, from there we can not really state
Reply
#3
Screenshot:
Image

full debug log <- NEW
http://pastebin.ca/1934526

Code in plugin
PHP Code:
cm = []
        if (
item("Title")):
            
cm.append( ( "Search on Title"'XBMC.RunPlugin(%s?path=/root/search&action=search&search=%s&)' % ( sys.argv[0], item('Title') ) ) )

        if 
len(cm) > 0:
            
listitem.addContextMenuItemscmreplaceItems=True 
We use this code to add a "search on title" to our video items.

When i entered favorites(which gives a list of favorites videos on youtube) argv looks like this.
PHP Code:
20:52:14 T:2933185392 M:1447645184  NOTICEYouTube-1.8.1 ARGV: ['plugin://plugin.video.youtube/''0''?path=/root/favorites&feed=favorites&login=true&'

Once we click on the "Search on Title" we get the following from the log:
PHP Code:
20:52:22 T:2933185392 M:1445101568  NOTICEYouTube-1.8.1 ARGV: ['plugin://plugin.video.youtube/''-1''?path=/root/search&action=search&search=OutKast - Hey Ya!&'

and then when we try to populate the list with items(the search results that is)

PHP Code:
20:52:23 T:2933185392 M:1438560256   ERROR:  AddItem called with an invalid handle.
20:52:23 T:2933185392 M:1438662656   ERROR:  AddItem called with an invalid handle.
20:52:23 T:2933185392 M:1438662656   ERROR:  EndOfDirectory called with an invalid handle

I hope this makes it clearer.
Reply
#4
What you want to do is refresh the folder with the new contents. I believe there's a container.refresh or some similar builtin command for this. It may be in the wiki if you're lucky.
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
#5
Code:
XBMC.RunPlugin(plugin) : Runs the plugin. Full path must be specified. Does not work for folder plugins

you're using isFolder = True ?
Reply
#6
ppic Wrote:
Code:
XBMC.RunPlugin(plugin) : Runs the plugin. Full path must be specified. Does not work for folder plugins

you're using isFolder = True ?
I'm not sure i understand.

We build a list of folders, like this.
PHP Code:
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=urllistitem=listitemisFolder=TruetotalItems=size

The redirect we are trying to make is to a folder (which is created with isFolder=True), but all the items in the target folder have isFolder = False, because it is a list of videos.
Reply
#7
i think jmarshall option is better for you, your plugin is using isFolder = True, it must be the problem, i've seen an old post from nuka talking about that.

http://forum.xbmc.org/archive/index.php/t-42073.html

hope this helps
Reply
#8
jmarshall Wrote:What you want to do is refresh the folder with the new contents. I believe there's a container.refresh or some similar builtin command for this. It may be in the wiki if you're lucky.

This seems to work, the plugin generates a new video listing with the results, but when i press the back button I'm returned to the root of the plugin and not the previous folder, which I imagine would be annoying to the end user.. Oo
Reply
#9
It might be useful if you state exactly what you're using so that others can see it as well (i.e. it shows up in a search). I'm sure we could refine the functionality should that be needed.
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
#10
jmarshall Wrote:It might be useful if you state exactly what you're using so that others can see it as well (i.e. it shows up in a search). I'm sure we could refine the functionality should that be needed.

Whoops sorry, well basically im calling the built-in function XBMC.Container.Refresh like you suggested, but with the path set to same location as one of the plugins "stored searches" (ie action=search&search="some user defined search") just with the search parameter changed to the title of the video in question.
Code:
cm.append( ( self.__language__( 30507 ), "XBMC.Container.Refresh(%s?path=%s&action=search&search=%s)" % ( sys.argv[0],  "/root/search", urllib.quote_plus( url_title ) ) ) )

When the user presses this context menu item, the current folder is refreshed / replaced with the contents of the search just like I intended, but when you press back to leave the search you're not returned to your previous location but instead the root of the plugin's folder tree.. Huh
Reply
#11
Try Container.Update instead of Container.Refresh - by default Container.Update does not reset the browsing history (you can pass the replace parameter to do that, whereby it's identical to Container.Refresh)

Cheers,
Jonathan
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
#12
jmarshall Wrote:Try Container.Update instead of Container.Refresh - by default Container.Update does not reset the browsing history (you can pass the replace parameter to do that, whereby it's identical to Container.Refresh)

Cheers,
Jonathan

Great it works just what we wanted, thanks a million Big Grin

And just for others trying to replicate the functionality, we now call:
Code:
cm.append( ( self.__language__( 30507 ), "XBMC.Container.Update(%s?path=%s&action=search&search=%s)" % ( sys.argv[0],  get("path"), urllib.quote_plus( url_title ) ) ) )

Resulting in the generation of a new folder listing with the search results, and allowing the user to continue their browsing by pressing the back button..
Reply
#13
brilliant. now you can use this to add a 'more videos from xxxx' feature, something i'm really missing from the old add-on Smile
Reply
#14
This is great. Spent 2 hours going crazy about "XFILE::CPluginDirectory::AddItem - called with an invalid handle."
Pneumatic | SABnzbd | XBMC that just works - openelec
Reply

Logout Mark Read Team Forum Stats Members Help
Context Menu item that creates a folder listing?0