livestream_saver icon indicating copy to clipboard operation
livestream_saver copied to clipboard

Add webhook notification

Open Ryu1845 opened this issue 2 years ago • 4 comments

Hello, I've seen your project and I think it could be quite useful to me and some of my friends. However I was wondering if it would be possible to add webhook support as an alternative to email notifications. We use Discord a lot and it's seems like the perfect way to notify our community.

I may be able to submit a pull request with the corresponding code if I have the time and you allow it.

Ryu1845 avatar Dec 19 '21 17:12 Ryu1845

You can already call webhooks by calling your own external scripts on each defined event (see the config file template). However, the events still lack some variables / placeholders right now, but let me know if you have specific values you'd like to see replaced in the commands. Right now there is only %VIDEO_URL% and %COOKIE_PATH% but we can add a lot more.

Anyway I think that's a good idea to have support for webhooks directly inside the program. The tricky part is to make a generic interface to support various webhook APIs, all the while allowing easy customization by the user. I can work out a quick and simple solution but feel free to submit patches if you have something more specific in mind. I'm thinking of having the payload JSON in the config file, and the API endpoint URL (with the authentication tokens) could be in both the config file and environment variables. Would that be enough?

What kind of information would you like to send? My guess: upcoming video detected, video added to channel, live stream started (and the corresponding metadata).

glubsy avatar Dec 19 '21 19:12 glubsy

That sounds perfect thank you. It's mostly live stream started, yeah. Useful variables would be channel name, title, also date maybe.

Ryu1845 avatar Dec 19 '21 21:12 Ryu1845

Added rudimentary webhook support in 187f9a451a617. Here is an example of what you can achieve on Discord with the current implementation of hooks: 2021-12-23_20-56-15

There might be bugs, so if you spot anything weird please let me know. I'll try to polish this a bit more later when I have some time. Also I hope the documentation is clear enough for you to be able to use it.

glubsy avatar Dec 24 '21 00:12 glubsy

Thank you and merry Christmas! I'll try this out later this week hopefully.

Ryu1845 avatar Dec 24 '21 23:12 Ryu1845