Kodi Community Forum

Full Version: AddContectMenuItem - Attempt to use invalid handle -1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Basically the issue i'm having is this;

Ive add a contextmenuitem to a directoryitem, when selected it uses xbmc.RunPlugin to call the plugin again but with parameters that will force a video download.
This was previously working fine, although I'm guessing the issue existed but didn't cause an error... the error that I'm currently getting is that the xbmc.RunPlugin has a handle of -1 and as such when I use xbmcplugin.getSetting it throws the WARNING: Attempt to use invalid handle -1

I've had a look online and have found some posts talking about it, but nothing that seems to resolve the problem, so would really appreciate a hand or a point to some more documentation that may come in handy resolving it.

Below, is what I'm using to get the content menu added'

Code:
u=sys.argv[0]+"?url="+detail['url']+"&mode="+str(detail['mode'])+"&name="+urllib.quote_plus(detail['title'].encode("utf-8"))+"&icon="+detail['icon']
liz=xbmcgui.ListItem(detail['title'].encode("utf-8"), iconImage=detail['icon'])
liz.setInfo(type=detail['type'], infoLabels={ "Title": detail['title'].encode("utf-8"),"Plot": detail['plot']} )
dwnld = (sys.argv[0] +
                "?url=" + urllib.quote_plus(detail['url']) +
                "&mode=" + str(9) +
                "&poster="+detail['poster']+
                "&extras="+detail['extras']+
                "&download=" + str(1) +
                "&fanart="+detail['fanart']+
                "&name=" + urllib.quote_plus(detail['extras2'].encode('utf-8')))
liz.addContextMenuItems([('Save', 'xbmc.RunPlugin('+dwnld+')')], replaceItems=False)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
(2016-06-23, 01:51)ptom Wrote: [ -> ]Basically the issue i'm having is this;

Ive add a contextmenuitem to a directoryitem, when selected it uses xbmc.RunPlugin to call the plugin again but with parameters that will force a video download.
This was previously working fine, although I'm guessing the issue existed but didn't cause an error... the error that I'm currently getting is that the xbmc.RunPlugin has a handle of -1 and as such when I use xbmcplugin.getSetting it throws the WARNING: Attempt to use invalid handle -1

I've had a look online and have found some posts talking about it, but nothing that seems to resolve the problem, so would really appreciate a hand or a point to some more documentation that may come in handy resolving it.

Below, is what I'm using to get the content menu added'

Code:
u=sys.argv[0]+"?url="+detail['url']+"&mode="+str(detail['mode'])+"&name="+urllib.quote_plus(detail['title'].encode("utf-8"))+"&icon="+detail['icon']
liz=xbmcgui.ListItem(detail['title'].encode("utf-8"), iconImage=detail['icon'])
liz.setInfo(type=detail['type'], infoLabels={ "Title": detail['title'].encode("utf-8"),"Plot": detail['plot']} )
dwnld = (sys.argv[0] +
                "?url=" + urllib.quote_plus(detail['url']) +
                "&mode=" + str(9) +
                "&poster="+detail['poster']+
                "&extras="+detail['extras']+
                "&download=" + str(1) +
                "&fanart="+detail['fanart']+
                "&name=" + urllib.quote_plus(detail['extras2'].encode('utf-8')))
liz.addContextMenuItems([('Save', 'xbmc.RunPlugin('+dwnld+')')], replaceItems=False)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)

Have you tried using xbmcaddon.getSetting rather than xbmcplugin.getSetting?

http://mirrors.kodi.tv/docs/python-docs/...addon.html

Code:
import xbmcaddon
value = xbmcaddon.Addon(id).getSetting('Setting')

id is optional, if missing Kodi will use the "active" addon
that works perfectly! thanks!
(2016-06-24, 00:44)ptom Wrote: [ -> ]that works perfectly! thanks!


Good to hear, I never even knew that plugin method existed Smile


Sent from my iPhone