I just managed to get Tecedi-Smartzap working with Kodi.
As a proper integration with Kodi will take some time, for now, I'm just giving basic information in this work log, I will provide the full working code and instructions later.
Linux distribution
I first tried OpenElec because I already knew this distribution, but it is not very hacker friendly, the maintainers chose to remove apt-get from it!
So I switched to OSMC instead. It is based on Raspbian but on Jessie, not on wheezy.
I couldn't find the python-rpi.gpio package so I had to install several packages to be able to install python-rpi.gpio with pip.
This should be enough to install it :
apt-get install gcc make python-dev python-pip
pip install RPi.GPIO
Kodi
I added the following script in /usr/local/bin/kodi-play-clip
#! /bin/sh
# we play the video clip with a JSON request
CMD="/usr/bin/curl --header 'Content-Type: application/json' --data-binary '{ \"id\": 1, \"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\": {\"item\": { \"file\": \""$1"\" } } }' 'http://127.0.0.1/jsonrpc'"
sh -c "$CMD"
echo
# we make a request to get the video clip length
LENGTH=$(/usr/bin/curl --header 'Content-Type: application/json' --data-binary '{"jsonrpc":"2.0","method":"Player.GetProperties","id":1,"params":{"playerid":1,"properties":["playlistid","totaltime"]}}' 'http://127.0.0.1/jsonrpc')
HOURS=$(echo $LENGTH | sed -r 's/.*hours..([0-9]*).*/\1/g')
MINUTES=$(echo $LENGTH | sed -r 's/.*minutes..([0-9]*).*/\1/g')
SECONDS=$(echo $LENGTH | sed -r 's/.*seconds..([0-9]*).*/\1/g')
# and we sleep for this amount of time so the script will exit only when the video is finished
TOTAL_SEC=$(( HOURS*3600 + MINUTES*60 + SECONDS ))
echo "sleeping for $TOTAL_SEC seconds"
sleep $TOTAL_SEC
So in switchdemo.py you just have to replace :VIDEO_PLAYER = '/usr/bin/omxplayer'
with :VIDEO_PLAYER = '/usr/local/bin/kodi-play-clip'
This is still very much a hack, there is no error checking. The final implementation will use Kodi Python API or the JSON one with PyCurl.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.