What is sys.argv[1]
#1
Sorry for the stupid question, but I can't seem to be able to find it out:

My sys.argv[1] is always 0. What does this value represent?

Thanks!

Axel
Reply
#2
no arguments to a programm .-)
Reply
#3
No....arguments are stored in sys.argv[2], right? Arguments are handled different here from my understanding
Reply
#4
sys.arg[1] or sys.arg[2] are all argument, each number separated by a comma
Reply
#5
Sorry I don't get it:
I call my plugin with

plugin://plugin.image.test/?url=123

sys.argv[0] = plugin://plugin.image.test/
sys.argv[1] = 0
sys.argv[2] = ?url=123
Reply
#6
sorry was talking about script
Reply
#7
http://www.crasseux.com/books/ctutorial/...-argv.html
sys.argv[1] being 0 is rather strange.
Reply
#8
its not really that apparent from the documentation but sys.argv[1] is an internal handle xbmc gives the plugin. Im guessing this is so that it can differentiate between different sessions and types:

http://xbmc.sourceforge.net/python-docs/xbmcplugin.html

There are some tricky situations when calling plugins which are described in this thread:
http://forum.xbmc.org/showthread.php?tid...=Runplugin
Reply
#9
yeah, I Saw this thread too, but It does not really help to figure out what's going on here...I don't even understand what this means:

Quote:handle the Plugin was started with.

Could someone bring some light in the darkness here?
Reply
#10
Sorry guys, but I am going nuts here:

Quote: liz=xbmcgui.ListItem('Strip','DefaultImage.png')
liz.setPath(thisisavalidurl) ##thisisavalidurl points to a picture
liz.setProperty("IsPlayable" , "True")
print 'sys.argv[1]='+str(int(sys.argv[1]))
itemnew = xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)

Will return this error:

Quote:21:21:42 T:4908 M:2574270464 NOTICE: -->Python Interpreter Initialized<--
21:21:43 T:4908 M:2572959744 NOTICE: sys.argv[1]=-1
21:21:43 T:4908 M:2572959744 ERROR: XFILE::CPluginDirectory::SetResolvedUrl - called with an invalid handle.

I just don't understand what's wrong here. Worse than that, I am not able to find any information about this problem.

I am just writing a beginners guide to plugin development, any information shared here will go into it - believe me it'll be worth it!

Thanks guys!
Reply
#11
you seems to launch it as a script, not as plugin .
Reply
#12
Here is how it's called:

Code:
urlpic = 'plugin://plugin.image.xkcd/?cat=view&url='+url
item = addItem(name, urlpic, 'DefaultImage.png')

with addItem being this:

Code:
def addItem(name,url,iconimage):
    u=url
    liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png",thumbnailImage=iconimage)
    liz.setInfo( type="Image", infoLabels={ "Title": name })
    liz.setProperty("IsPlayable" , "True")
    item=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz)
    return item
Reply
#13
strange code, i don't get the goal.
you have to use builtins in context menu, you can't use a python function.
Reply
#14
Spaggi Wrote:Here is how it's called:

Code:
urlpic = 'plugin://plugin.image.xkcd/?cat=view&url='+url
item = addItem(name, urlpic, 'DefaultImage.png')

with addItem being this:

Code:
def addItem(name,url,iconimage):
    u=url
    liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png",thumbnailImage=iconimage)
    liz.setInfo( type="Image", infoLabels={ "Title": name })
    liz.setProperty("IsPlayable" , "True")
    item=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz)
    return item

As far as i can see this is the code that fails, not the code that calls it, which was what ppic asked for, basically the handle is determined by the way you launch your code. E.g. if you're triggering it from a context menu you need to use something like:

Code:
cm.append( ( self.__language__( 30514 ), "XBMC.Container.Update(%s?path=%s&action=search&search=%s)" % ( sys.argv[0],  get("path"), url_title ) ) )

or

Code:
cm.append( ( self.__language__( 30505 ), 'XBMC.RunPlugin(%s?path=%s&action=refine_user&search=%s&)' % ( sys.argv[0], item("path"), item("search") ) ) )

or

Code:
cm.append( (self.__language__(30520), "XBMC.PlayMedia(%s?path=%s&action=play_video&quality=1080p&videoid=%s)" % ( sys.argv[0],  item("path"), item("videoid") ) ) )

The XBMC.Container.Update, XBMC.RunPlugin or XBMC.PlayMedia part determines what handle the plugin is launched with, and in turn determines what the plugin gets to do i.e. generate a folder listing, background work or playing a video. It would help if you could tell us what you're trying to achieve and how you're launching this code you're working on. Smile
Reply
#15
Hey guys,

I think there is a misunderstanding here. What I am trying to do is have a directory filled with Directoryitems assigned to url's. This directory is created when starting my plugin.
Every item in this list is created by this code:

Code:
urlpic = 'plugin://plugin.image.xkcd/?cat=view&url='+url
item = addItem(name, urlpic, 'DefaultImage.png')

You can also subsitute plugin://plugin.image.xkcd/ with sys.arv[0]

When calling one of those url, I want to scrape another url (the url of the actual picture) and display this url's target with the setResolvedUrl command. This is triggered because the variable cat = view

I hope this clears everything up a bit....I am not calling the plugin with a command, I am just using the plugin url given to a DirectoryItem - I thougt this works?

But thanks HenrikDK, I will try if I can work something out with your help.

Ah btw...I am not doing anything in the context menu at all...did I write that somewhere?
Reply

Logout Mark Read Team Forum Stats Members Help
What is sys.argv[1]0