Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acamilleri/go-plexhooks
Library to listen Plex webhook events and execute actions.
https://github.com/acamilleri/go-plexhooks
grafana plex plex-media-server webhook
Last synced: about 1 month ago
JSON representation
Library to listen Plex webhook events and execute actions.
- Host: GitHub
- URL: https://github.com/acamilleri/go-plexhooks
- Owner: acamilleri
- License: apache-2.0
- Created: 2020-08-08T19:11:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T08:56:43.000Z (over 1 year ago)
- Last Synced: 2024-11-15T21:45:44.051Z (about 2 months ago)
- Topics: grafana, plex, plex-media-server, webhook
- Language: Go
- Homepage:
- Size: 92.8 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Plex Hooks
[![Go Report Card](https://goreportcard.com/badge/github.com/acamilleri/go-plexhooks)](https://goreportcard.com/report/github.com/acamilleri/go-plexhooks)
Library to listen [Plex Webhook Events](https://support.plex.tv/articles/115002267687-webhooks/) and execute actions.
**Plex Webhooks require a Plex Pass subscription**
## Installation
Use the library in your own app to register your actions.
```bash
go get github.com/acamilleri/go-plexhooks
```## Usage
You can check a real world example with [myplexhooks](https://github.com/acamilleri/myplexhooks) repository.
Example:
```golang
package mainimport (
"net""github.com/sirupsen/logrus"
"github.com/acamilleri/go-plexhooks"
"github.com/acamilleri/go-plexhooks/plex"
)type MyActionOnMediaPlay struct{}
func (a *MyActionOnMediaPlay) Name() string {
return "MyActionOnMediaPlay"
}func (a *MyActionOnMediaPlay) Execute(event plex.Event) error {
fmt.Printf("I'm print a message when i received a MediaPlay event")
return nil
}func main() {
listenAddr, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:8080")
if err != nil {
panic(err)
}actions := plexhooks.NewActions()
actions.Add(plex.MediaPlay, &MyActionOnMediaPlay{})app := plexhooks.New(plexhooks.Definition{
ListenAddr: listenAddr,
Actions: actions,
Logger: plexhooks.LoggerDefinition{
Level: logrus.InfoLevel,
Formatter: &logrus.JSONFormatter{},
},
})
err := app.Run()
if err != nil {
panic(err)
}
}
```### Metrics
The Run function running a metrics handler to have some metrics about the
events handler and actions executed.Metrics are expose at `/metrics` path in [Prometheus](https://prometheus.io/) format.
You can find all metrics [available here](metrics.go)
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.