xbmcplugin: Running a python command or online video

first of all sorry about my poor englis.

I'm self learning to build simple plugins. My objetive is to run an external program from kodi but im unable to do it. I have some code like this that is partially working:

import sys
import xbmcgui
import xbmcplugin
import subprocess

addon_handle = int(sys.argv[1])

xbmcplugin.setContent(addon_handle, 'files')

url = 'C:\\SOFTWARE\\vid.mp4'
li = xbmcgui.ListItem('Video local')
li.setProperty('IsPlayable', 'true')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

url = 'subprocess.call(["C:\SOFTWARE\TestFile.exe", "-k"])'
li = xbmcgui.ListItem('Video online')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)


The first "listitem" object is playing the video but only if I open the contextual menu and select "Play", when pressing "Enter" or clicking the item it isn't playing nothing. I also have tried to make this with an online file, just changing the URL value, but it is not working even when I have access to the file running it in my browser.
The second item is what I want to make work. I just want to press "enter" on the item or cliking it and run a python command, not an URL, but I don´t know how to manage it.

Thanks for the replies!
Thread moved to addon development
|Banned add-ons (wiki) Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

My Blog Posts
Thread Rating:
  • 0 Vote(s) - 0 Average

Logout Mark Read Team Forum Stats Members Help
xbmcplugin: Running a python command or online video00