Feature request : do "stuff" on recording started

Would be nice to be able to run a script when a recording has started. In my case, I want to force an update to my Kodi library. Linux guys can use inotify and on Windows it’s real easy to throw together a service in C# using file watchers.

However, the only option for NAS users is cross compiling inotify-tools for their particular architecture and that’s way beyond me. Either that or Kodi constantly polling folders over the network and that’s just ugly.

Sounds like kodi is running on a different machine? What kind of computer is it? Is there a command you can run there to tell it to refresh?

You can run a curl from a remote box to update Kodi.

curl --data-binary ‘{ “jsonrpc”: “2.0”, “method”: “VideoLibrary.Scan”, “id”: “mybash”}’ -H ‘content-type: application/json;’ http://User:[email protected]:port/jsonrpc

What he said :slight_smile: Thanks for saving me the time looking it up, Tim !

Oh, sorry. Kodi’s running on a couple Pi’s, Shield TV and a Nexus Player.

Here’s a shell script you could run in a screen or something which would run the wakeup command every time a new recording started:

#!/bin/bash
while true; do
  curl http://x.x.x.x:8089/dvr/events/subscribe | grep -o files.created | xargs -n1 -I % curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://User:[email protected]:port/jsonrpc
  sleep 30
done

That’s pretty much exactly what I need. Thanks. I’ll have to see if I can wrap that up into a startup service.

Is there a cheap and cheerful way of running this in the background ? I have a start|stop|reload|status script set up but it runs it in the foreground which I wasn’t quite expecting.