dgw / plex-pushover

A simple plex webhook to send a Pushover notification every time someone starts playing media on your server
MIT License
5 stars 3 forks source link

Batching track notifications #21

Open dgw opened 5 years ago

dgw commented 5 years ago

Currently, a notification is sent for every track that starts playing (except when a Plex Media Server or Plex client bug causes the webhook not to fire, as in the recent Android music player beta). That gets awfully spammy for long listening sessions.

In addition to configuring notification types (#19), I can definitely see a use case for batching music notifications. I'm not sure how difficult it would be to implement without refactoring the code—haven't even looked at the code in a few months—but it seems useful.

Instead of sending a notification for every track as soon as it's started, the webhook service could store a buffer of track data and send it after a timeout (or when the queue reaches a certain size). Of course, this leads to a risk of losing notifications if the webhook server crashes. I'd also need to look into whether Node.js has a shutdown hook this service could use to flush its queued notifications before being shut down gracefully, at least. Even if there's no good safety net for actual crashes, it would handle reboots etc.