Solved sys.argv[1] set to -1 after first call
#1
my plugin is like this

Code:
pluginPid    = int(sys.argv[1])
print "JWORG pluginPid " + str(pluginPid)

...

def showVideoIndex(start):
    global pluginPid

       ...
       for ....
                  .....
                  params = {"content_type" : "video", "start" : next_start}
                  url = sys.argv[0] + '?' + urllib.urlencode(params)
                  xbmcplugin.addDirectoryItem(pluginPid, url,listItem)  
    
    xbmcplugin.endOfDirectory(pluginPid)
        

# Stampo per debug gli argomenti della chiamata
params          = urlparse.parse_qs((sys.argv[2])[1:])
content_type = params["content_type"][0]

start = 0
try:
    start = params["start"][0]        
except:
    pass

if content_type == "video" :
    showVideoIndex(start);

When i first time enter into plugin, i execute showVideoIndex(0) and all is working; a video appear a list of five items

When I click on one item, the plugin is reloaded, but my pluginPid is set to -1, so when i use this pid in addDirectory, i got an "invalid handler -1" error

What can I do to diagnose and/or fix it?
Reply
#2
... help me please ...

I reduced the code to this:

Code:
import xbmcplugin
import xbmcgui
import sys

import urllib

thisPlugin=int(sys.argv[1])

def showVideoIndex():
    global thisPlugin

    url = sys.argv[0]
    listItem = xbmcgui.ListItem("This is my plugin PID " + str(thisPlugin) )
    xbmcplugin.addDirectoryItem(handle=thisPlugin, url=url, listitem=listItem)  
    xbmcplugin.endOfDirectory(handle=thisPlugin)

showVideoIndex();

But I got the same problem...
Reply
#3
Solved: it was the addon folder name: it was created with '_' instead of '.' beetween words
Reply

Logout Mark Read Team Forum Stats Members Help
sys.argv[1] set to -1 after first call0