Python & OSMC, get song's info!

Hello everyone, this is my first post here!

Situation: I developed a script in order to print on my LCD 16x2 connected to my RPi 3 the name of the song playing and the artist. I first wrote my (Python) script when I was running Rune Audio (basically osmc but only for music (http://www.runeaudio.com/), and now I’d like to do the same thing with Kodi. The good part about Rune is that it uses MPD to stream audio and can be easily controlled through Python with the “mpd” library, but that doesn’t seem to be the case in Kodi as it doesn’t use mpd (isn’t it?), therefore I’m quite lost. All I need is a way to get information about the song playing in Kodi, via Python! Isn’t there a library for that? Something that simply gives me info about what Kodi is playing? I found out about something called xbmc-json, but I haven’t really understood how it works and I’d like someone to help me find an easy way to get the info I need…

Thank you very much people, have a nice day!

If you get lcdproc and install the respective kodi addon, this is something that will be done automatically.

Search the forum for hd44780

If you want to do it yourself so you have more control, the rpc interface is very easy to use from python… http://kodi.wiki/view/JSON-RPC_API/Examples#What_is_playing

in bash you would do this to get the active players
curl --data-binary ‘{“jsonrpc”: “2.ActivePlayers”, “id”: 1}’ -H ‘content-type: application/json;’ http://localhost:8088/jsonrpc

Return looks like this
{“id”:1,“jsonrpc”:“2.0”,“result”:[{“playerid”:0,“type”:“audio”}]}
or if nothing is playing
{“id”:1,“jsonrpc”:“2.0”,“result”:}

You pass the playerid from above to the next command
curl --data-binary '{“jsonrpc”: “2.0”, “method”: “Player.GetItem”, “params”: { “properties”: [“title”, “album”, “artist”, “duration”, “thumbnail”, “file”, “fanart”, “streamdetails”], “playerid”: 0 }, “id”: “AudioGetItem”}
’ -H ‘content-type: application/json;’ http://localhost:8088/jsonrpc

and get this
{“id”:“AudioGetItem”,“jsonrpc”:“2.0”,“result”:{“item”:{“album”:“In Your Room”,“artist”:[“Yazoo”],“duration”:191,“fanart”:“”,“file”:“/media/Popcorn/Music/Yazoo/In Your Room/01 - Don’t Go.mp3”,“id”:13454,“label”:“Don’t Go”,“thumbnail”:“image://%2fmedia%2fPopcorn%2fMusic%2fYazoo%2fIn%20Your%20Room%2fcover.jpg/”,“title”:“Don’t Go”,“type”:“song”}}}

In python you would use the request library to send the commands, and the json library to read the results. I did something similar a while back for pushbullet but dont have it to hand at the mo. Hopefully that will point you in the right direction, if you get stuck I’ll dig out a python example