Linux Running Bash Scripts from Kodi
#1
Hi,

Apologies if this has been covered before, I am unable to find relevant information.

I would like to execute a bash script from a kodi plugin. I have 7 bash scripts, each one triggers a different set of xdotool commands on another ubuntu dekstop "changing channel" essentially. The entire desktop (on the ubuntu machine) is captured by Open Broadcaster Software and sent to my HTPC which has an nginx instance running on it. This allows me to have an rtmp://192.168.1.103/live/stream running from the nginx server on localhost. So, my bash scripts choose the channel, and that one stream allows me to view the channels. I will not elaborate on the reasons for this complicated approach unless anybody is interested. This is how it has to be, however.

I used advanced launcher to achieve this previously, but alas, Angelscry has taken down all the repos for his work. Advanced laucnher is no more, it seems.

I am a novice programmer, forgive me.

I have tried to use this to try and decipher this stuff, and I have completed 40% of the codeacademy python tutorial, so I figured I would give it a bash, but I didn't get very far. This is most likely due to me not being good enough, so I am asking for help.

I got this far:

Code:
import sys
import xbmcgui
import xbmcplugin

addon_handle = int(sys.argv[1])

xbmcplugin.setContent(addon_handle, 'movies')

url = 'rtmp://192.168.1.103/live/test'
li = xbmcgui.ListItem('SuperSport 1', iconImage='/home/mark/.kodi/addons/plugin.video.example-master/resources/images/SuperSport_HD.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

xbmcplugin.endOfDirectory(addon_handle)

..but that only plays the rtmp link. I want something that executes a bash script instead of playing a file. My bash files contain json commands to play the rtmp link by means of a .strm file.

What do i do to get this right? How far off am I?

Any help would be appreciated. Even just a string for me to google would be appreciated.
Reply
#2
checkout subprocess.call

https://docs.python.org/2/library/subprocess.html
Reply
#3
Thanks for the tip.

It all makes sense in my head, but I still cant get it right:

Am I correct in assuming that I need to replace the current URL with a "subprocess.call('ss1', shell = True)" - because if I put that in a separate file and execute it in the terminal, it works and runs my script. If I replace the URL in my main.py, the script will no longer run on kodi.

As I said earlier, I am a novice, feel free to shout at me and tell me to google more. If you could tell me what to google would be great though.
Reply
#4
(2016-01-07, 13:42)markzilla Wrote: Thanks for the tip.

It all makes sense in my head, but I still cant get it right:

Am I correct in assuming that I need to replace the current URL with a "subprocess.call('ss1', shell = True)" - because if I put that in a separate file and execute it in the terminal, it works and runs my script. If I replace the URL in my main.py, the script will no longer run on kodi.

As I said earlier, I am a novice, feel free to shout at me and tell me to google more. If you could tell me what to google would be great though.

subprocess.call, as it name implies, calls an external script of some sort. So if you have a working bash script that does what you want, then all you need to do is call the script using subprocess.call. If you're wanting to pass an argument to the shell script, I'd have to do some more poking around. I think subprocess.call allows for that though. You might check the documentation.
Reply
#5
Do you have any Python knowledge?

If you do check the def terminal module in here:
located in file name: shared_modules.py

https://github.com/finalmakerr/featheren...ce.service
Reply

Logout Mark Read Team Forum Stats Members Help
Running Bash Scripts from Kodi0