SceneSwitcher
SceneSwitcher copied to clipboard
Feature request: Web request action (HTTP call)
I know I could use a Run action to execute a tool like curl, but being able to do it directly from SceneSwitcher would be a lot more comfortable, since no external tool installations are needed. Plus it's faster, which is important when doing synchronized things where a few milliseconds can make a difference.
This would be useful to trigger actions via HTTP interfaces in other tools outside of OBS that use web-request based APIs. Or for me personally: trigger actions in other OBS instances using a tool that provides an HTTP interface for OBS based on obs-websocket, giving me basically infinite power of triggering a specific action in one OBS based on conditions met in another.
I envision an option to choose from at least the most common GET and POST methods, where GET only offers a URL field to enter the target URL and POST also a field for raw post data.
A bonus would of course be also other methods (DELETE/PUT/PATCH...) and options to configure the header.
I too have bee wanting this. Using run and curl.exe works.. But it still has to run the cmd window and all. A direct get request would be really nice.
I quickly implemented the action type "HTTP" with the linked PR:
It should support GET and POST, but to be honest my testing was very shallow as I am not really familiar with web requests.
So I would appreciate if you could give this a try and report if it is behaving as you expected.
A build for OBS 28 should be available here in a few minutes: https://github.com/WarmUpTill/SceneSwitcher/actions/runs/2892112722
I can you are interested in the implementation details - the functionality is just relying libcurl to do the work: https://github.com/WarmUpTill/SceneSwitcher/blob/d90273d45a31b0c15e8c61c3965e86eef7e2acd3/src/macro-core/macro-action-http.cpp#L19-L35
Awesome man! Will test this out. Will you also add a response function? It would be nice to set up macros that fires depending on the response of a GET-request.
Due to the http integration, windows defender doesn't seem to like that. False positive for sure, but, not sure if you are able to work around these warnings as they might frighten some users
So I tried using GET to a webhook I have on an online service. It doesn't trigger it. Doing it in cmd with curl works fine, but not via this. So, maybe something wrong is happening
Due to the http integration, windows defender doesn't seem to like that. False positive for sure, but, not sure if you are able to work around these warnings as they might frighten some users
Ah, thanks for pointing that out! Not really much I can do about it. Will ask Microsoft Defender Support to look into it. Had this happen a few years back already and was resolved rather quickly.
UPDATE: Already got feedback. Apparently with the newest Windows Defender definitions the files are no longer being flagged as a virus. This also matches my observations. Yesterday evening it was still flagged by Microsoft on VirusTotal while today it is not. So topic should be resolved.
So I tried using GET to a webhook I have on an online service. It doesn't trigger it. Doing it in cmd with curl works fine, but not via this. So, maybe something wrong is happening
Is there any error or something of that sort that I could look into? My tests basically revolved around spinning up a local python http server and logging the incoming GET / POST requests.
~~EDIT: Could it be that the issue was that the default timeout value is at 0 seconds thus aborting the connection immediately?~~
I think I have identified a possible reason for your observed issue: As I did not set a function to receive any data after the GET request was sent, once the server tried to reply the connection was already closed. This does not seem to cause issues for all types of GET requests it seems.
A new build where this behaviour was changed can be found here in a few minutes: https://github.com/WarmUpTill/SceneSwitcher/actions/runs/2897614656
Let me know if that changes anything on your end! :)
Right...I feel awkward. I tested by running the macro via the run macro-button, and that worked. Turns out the service wasn't even running when I was testing out macros lol. Started it, and it works just fine :)
Haven't gotten around to test it myself yet but from what I read here I guess it will work fine. Thanks a lot for implementing this!
Thats great to hear, im sorry for reposting it. I had the old version so i had no idea it was added, i should have updated first before posting this. Again thank you for your work.
Is there a version of this available for 1.17.7. I'm stuck here because of other plugins still not compatible with v28.
Is there a version of this available for 1.17.7. I'm stuck here because of other plugins still not compatible with v28.
No there is not unfortunately. If you need this functionality urgently I can try to see if I can create a separate branch and rebuild the plugin for the OBS 27. Alternatively you could use the "Run" action and use the "curl" binary to do the same thing.
I did try that by making a batch file (Windows 10) but it goes into a loop and keeps running it over and over. If this could just happen one time per active scene that would be fine. The URL is a command that activates a light fade. The nature of the fade command is to reset the lights to full brightness in order to do the fade.
Quick TLDR:
I have a batch file to a node-red URL (curl http://localhost:7000/dim1234) that fades lights. Right now, using the RUN command with the batch file, when the scene becomes active, the batch file runs repeatedly and queues the node-red fade over and over so the lights continuously fade cycle again and again. The nature of the command is (which there is no way to control) the lights reset to bright and then fade.
So, the bottom line, I need the run command to not rerun after the batch file is finished. Also, as I said, I'm stuck on 1.17.7 until there is an update to one of my necessary plugins.
I hope that is clear. Thank you for your great plugin and your attention to posts! 2nd to none!
Ok, I found what I needed. I Went back in and saw that I needed to check "Perform actions only on condition change" and then set up an if scene is and if scene is not. Working great! Thanks again for (IMHO) the BEST plugin for OBS!