I’m developing a sort of kiosk that uses a Raspberry Pi and will have videos playing constantly. I’m looking for a way to control playback and see what’s currently playing with Python.
Searching around the forums, it looks like I should be looking into the XBMC documentation, but I haven’t been able to get very far. I used pip to install xbmc-client but that search turned out to be fruitless. Threads like this one lead me to believe I’m in the right direction.
Here’s my question: How do I utilize the existing code library for interfacing with XBMC/Kodi with Python on OSMC?
Kodi has a well defined JSON-RPC API. You should use that. We already include
kodi-send and it is in the default path. This will provide you with a wealth of functionality.
Thank you for your quick reply. After finding some examples of JSON-RPC, it definitely seems like the direction I want to go. The only problem is, when I run some basic commands, I keep getting this error returned:
requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))
The kodi-send command works flawlessly, but I need to be able to get information back from Kodi. Is there a setting I need to change in OSMC to enable this?
Make sure you have enabled ‘Allow other systems to control this…’
Thank you for your help. For anyone else with this problem, here are the steps I did to fix the issue:
I was working on getting this example working. In order to fix the “Connection refused” problem, I enabled (white box instead of grey) the following settings in OSMC:
- Settings/Services/Web server/Allow remote control via HTTP
- Settings/Services/Remote Control/Allow remote control by programs on this system
- Settings/Services/Remote Control/Allow remote control by programs on other systems