Kodi Community Forum
Command to get current playing filename (not title) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: Command to get current playing filename (not title) (/showthread.php?tid=365953)



Command to get current playing filename (not title) - Flash3d - 2021-12-12

Hi, I'm looking for a command to get the current playing filename (so not just the currently playing movie title).
Example: moviename 1080p DTSHD.mkv 

Is there a (curl?) command I can use? Preferable a command with username and password in the example.
Something I could use in Home Assistant? Would love to run a script from HA to get the current playing filename from Kodi.

There is a Kodi integration in HA but that shows the movie title and not the filename. 

Tia.


RE: Command to get current playing filename (not title) - Flash3d - 2021-12-16

Anybody? Would really love this getting this to work. 
Want too use it to automatically control a masking system for my projection screen.


RE: Command to get current playing filename (not title) - SEIKT - 2021-12-16

python:

jsonRequest = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"properties": ["file"], "playerid": 1}}')
filePath = json.loads(jsonRequest.encode("utf-8"))["result"]["item"]["file"]
fileName = os.path.basename(filePath)


http://localhost:8080/jsonrpc?request={"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"properties": ["file"], "playerid": 1}}


RE: Command to get current playing filename (not title) - Flash3d - 2021-12-16

Thank you very much!! that works.
Now the next step is getting the "file" data into Home Assistant, will post a question on the HA forum.


RE: Command to get current playing filename (not title) - Rembrandt - 2022-01-20

How would one do this in BASH from an RPi4 running Raspbian ?

Thanks

Rembrandt