Embed plugin inside script

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Bstrdsmkr Offline
Fan
Posts: 655
Joined: Oct 2010
Reputation: 12
Post: #11
Try using RunPlugin('plugin://script.video.something/?mode=0') first

Failing that, how are you calling addItem()? Make sure you're creating it as a folder if the items you're adding aren't the end of the chain.
find quote
bossanova808 Offline
Member+
Posts: 1,532
Joined: Sep 2009
Reputation: 20
Location: Melbourne, Australia
Post: #12
Ok running it that way gives me an invalid handle error - the sys.argv dump shows:

Code:
chooser="RunPlugin(plugin://plugin.program.xsqueezechooser/?mode=0)"
      xbmc.executebuiltin(chooser)


13:06:17 T:6828  NOTICE: Called as: ['plugin://plugin.program.xsqueezechooser/', '-1', '?mode=0']

..I guess the -1 is the handle?

addItem is being called:

Code:
#dummy nodes for root menu for modes

def buildRootListing():

  addNode("New Music","",1,"")
  addNode("Albums","",2,"")


def addNode(name, url, mode, iconimage, album="", artist=""):

        u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name) +"&album="+urllib.quote_plus(album) +"&artist="+urllib.quote_plus(artist)

        is_ok=True

        listItem=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
        listItem.setInfo( type="Video", infoLabels={ "Title": name } )

        is_ok=xbmcplugin.addDirectoryItem(thisPlugin,url=u,listitem=listItem,isFold​er=True)
        return is_ok
find quote
Bstrdsmkr Offline
Fan
Posts: 655
Joined: Oct 2010
Reputation: 12
Post: #13
Yeah, -1 is the handle. That usually happens when the current directory is not created as a directory. Xbmc expects everything currently displayed to be playable, not build a new list.

How is xbmc.executebuiltin(chooser) being called? Is it from a context menu?
find quote
bossanova808 Offline
Member+
Posts: 1,532
Joined: Sep 2009
Reputation: 20
Location: Melbourne, Australia
Post: #14
it's bound to an action in my windowXML:

Code:
#chooser
    elif action == ACTION_CODES['ACTION_SHOW_INFO']:
      Logger.log("### Starting Chooser...")
      ####chooser = "RunAddon(plugin.program.xsqueezechooser,mode=0)"
      chooser="RunPlugin(plugin://plugin.program.xsqueezechooser/?mode=0)"
      xbmc.executebuiltin(chooser)

...and yeah I want it to start at root precisely because it's remembering where it was (actually jsut a dummy message that says 'album queued' - and this retriggers the adding of the album...I really need to be able to force it back to the root...
(This post was last modified: 2012-05-09 05:51 by bossanova808.)
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #15
Activatewindow() which runaddon() should call should work. I see you have it commented out. Did you try it? A -1 handle just means invalid. runplugin is used when you're calling back to your plugin to do a task. Activatewindow or runaddon is when you want a new listing.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
bossanova808 Offline
Member+
Posts: 1,532
Joined: Sep 2009
Reputation: 20
Location: Melbourne, Australia
Post: #16
The commented out one is the way I do it, actually. But then I can't pass arguments and force the plugin to start at the root each time.

So with RunAddon, it re-enters the plugin wherever it finished last time....
find quote
spiff Offline
Grumpy Bastard Developer
Posts: 12,187
Joined: Nov 2003
Reputation: 82
Post: #17
yeah, i totally screwed up the params on RunAddon i see. what should work is

xbmc.executebuiltin('ActivateWindow(Programs,plugin://plugin.program.xsqueezechooser/?mode=0)')

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.
find quote
bossanova808 Offline
Member+
Posts: 1,532
Joined: Sep 2009
Reputation: 20
Location: Melbourne, Australia
Post: #18
Yep that does it. Thanks!

Don't be too hard on yourself mate, a few of the lines you've written work ok Wink
find quote
Post Reply