Webcam script on start/end of watching

Camera model
android phone with ip Webcam app
What is the problem?
ip webcam app have problem with automaticaly turn on flash light when somebody is viewing (at least it doesnt work every time ) but i can turn on/off flash light with http request "CAMERAIP:8080/enabletorch"
so i wonder if there is a way to run simple script ("curl -s "CAMERAIP:8080/enabletorch"") when webcam stream opens/closes in octoprint.
What did you already try to solve it?
i can do it with custom action command but better way would be to automate this because monitored printers are in dark enviroment

thank you for answer

You might add two custom control buttons to your Control tab which call one or two scripts which do whatever.