2017-01-23, 22:50
Hi Shogun, I think the best way to get the song_id from a song being played is through a json rpc call.
Code:
import xbmc, json
jsonGetPlaylistPos = '{"jsonrpc":"2.0", "method":"Player.GetProperties", "params":{"playerid":0,"properties":"playlistid","position"]},"id":1}'
jsonGetPlaylistItems = '{"jsonrpc":"2.0", "method":"Playlist.GetItems", "params":{"playlistid":0,"properties":["file"]}, "id":1}'
# get song position in playlist
playerProperties = json.loads(xbmc.executeJSONRPC(jsonGetPlaylistPos))
position = playerProperties['result']['position']
# get song id
playlistItems = json.loads(xbmc.executeJSONRPC(jsonGetPlaylistItems))
song_id = utils.paramsToDict(playlistItems['result']['items'][position]['file']).get("song_id")