navidrome / navidrome

🎧☁️ Modern Music Server and Streamer compatible with Subsonic/Airsonic
https://www.navidrome.org
GNU General Public License v3.0
10.6k stars 804 forks source link

User webhooks #478

Closed tcurdt closed 8 months ago

tcurdt commented 3 years ago

As mentioned in #18 it would be nice to allow user to configure webhooks to pass events to other system like e.g. Zapier. The following events come to mind:

  1. play with attributes artist, album, track, played time, total time, cover url
  2. scrobble (played 90%) with attributes artist, album, track, played time, total time, cover url
  3. pause with attributes artist, album, track, played time, total time, cover url
  4. added to starred with attributes artist, album, track, total time, cover url
  5. removed from starred with attributes artist, album, track, total time, cover url
  6. added to playlist with attributes TBD
  7. remove from playlist with attributes TBD

ATM I am mostly interested in 1., 2. and 3.

MoralCode commented 3 years ago

there don't seem to be any existing go libraries for sending webhooks. i might play around with trying to make one based on https://freek.dev/1383-sending-and-receiving-webhooks-in-laravel-apps.

deluan commented 3 years ago

@MoralCode I don't see a need for a library to send webhooks... They are usually an HTTP GET/POST, and GoLang's http client is straightforward and simple enough. Maybe I'm missing your point?

MoralCode commented 3 years ago

I was mostly thinking of a library just as a way to make implementing webhooks easy and simple for applications like Navidrome. To me it seems like the hardest part of implementing webhooks is the setup process of collecting the settings from the user and storing them.

I was thinking a library could be useful for simplifying this storage of webhook configurations so an app like Navidrome would just need to pass in the settings from the user and an internal key/identifier for representing that particular webhook-able "event". Whenever the app decides is appropriate for the webhook to be called, it could just be a one-liner to the effect of webhooks.trigger('webhook-event-id-here') with optional parameters for passing in headers and a body according to whatever format Navidrome chooses to implement. Essentially the library would primarily handle the storage and lookup of stored webhook configuration(s) for the event (such as the URL and HTTP method to use).

MoralCode commented 3 years ago

I have something basic thrown together at https://github.com/MoralCode/go-event-webhooks and am starting to see how simple the actual sending of a webhook is. My plan now is to start looking into how user settings are stored and retrieved to see where/how webhooks could be integrated into navidrome

MoralCode commented 3 years ago

@tcurdt is there a particular service (you mentioned Zapier) that you are interested in sending these webhooks to at first? just added https://github.com/MoralCode/go-event-webhooks/issues/6 tas a TO-DO item for the webhook library I am making for this and am curious if any particular service should be prioritized

tcurdt commented 3 years ago

@MoralCode I used Zapier just as one of the common examples. I'd probably send them to n8n or nodered instead. Or even write my own service.

deluan commented 3 years ago

I think another good example is IFTTT

MoralCode commented 3 years ago

awesome! I added those as ideas to the issue I mentioned within the library.

tcurdt commented 2 years ago

Seems there is overlap with https://github.com/navidrome/navidrome/issues/246

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Navidrome team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

tcurdt commented 1 year ago

It would still be "nice to have" but I think we could close this issue by just having the last.fm scrobbler URL be configurable. It's not yet, is it?

https://github.com/navidrome/navidrome/blob/master/conf/configuration.go#L103

deluan commented 1 year ago

2229 will handle 1 and 2. 3 is not currently possible as the clients do not send this info to the server. The other will be eventually implemented

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Navidrome team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

github-actions[bot] commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.