Kodi Community Forum
xbmcplugin: Running a python command or online video - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: xbmcplugin: Running a python command or online video (/showthread.php?tid=348240)



xbmcplugin: Running a python command or online video - Guijar - 2019-10-10

Hi,

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)

xbmcplugin.endOfDirectory(addon_handle)

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!


RE: xbmcplugin: Running a python command or online video - DarrenHill - 2019-10-13

Thread moved to addon development