docs: update plugin registration docs

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-12-30 17:30:28 -05:00
parent 633a26a273
commit 221ccdc18d
3 changed files with 22 additions and 20 deletions

View File

@ -13,7 +13,7 @@ This folder contains example plugins demonstrating various capabilities and lang
| [coverartarchive-py](coverartarchive-py/) | Python | MetadataAgent | Cover Art Archive |
| [nowplaying-py](nowplaying-py/) | Python | Scheduler, SubsonicAPI | Now playing logger |
| [webhook-rs](webhook-rs/) | Rust | Scrobbler | HTTP webhook on scrobble |
| [library-inspector](library-inspector-rs/) | Rust | Library, Scheduler | Periodic library stats logging |
| [library-inspector-rs](library-inspector-rs/) | Rust | Library, Scheduler | Periodic library stats logging |
| [discord-rich-presence-rs](discord-rich-presence-rs/) | Rust | Scrobbler, Scheduler, WebSocket, Cache, Artwork | Discord integration (Rust) |
## Building

View File

@ -22,24 +22,26 @@ It relies on several host services declared in the manifest:
## Architecture
The plugin registers capabilities by exporting the required functions:
The plugin registers capabilities using the PDK Register pattern:
```go
// Scrobbler capability
//export nd_scrobbler_is_authorized
//export nd_scrobbler_now_playing
//export nd_scrobbler_scrobble
import (
"github.com/navidrome/navidrome/plugins/pdk/go/scrobbler"
"github.com/navidrome/navidrome/plugins/pdk/go/scheduler"
"github.com/navidrome/navidrome/plugins/pdk/go/websocket"
)
// WebSocket callback capability
//export nd_websocket_on_text_message
//export nd_websocket_on_binary_message
//export nd_websocket_on_error
//export nd_websocket_on_close
type discordPlugin struct{}
// Scheduler callback capability
//export nd_scheduler_callback
func init() {
scrobbler.Register(&discordPlugin{})
scheduler.Register(&discordPlugin{})
websocket.Register(&discordPlugin{})
}
```
The PDK generates the appropriate export wrappers automatically.
When `NowPlaying` is invoked the plugin:
1. Loads `clientid` and user tokens from the configuration (because plugins are stateless).
@ -96,11 +98,11 @@ Folder = "/path/to/plugins"
## Files
| File | Description |
|--------------|--------------------------------------------------------|
| `main.go` | Plugin entry point, capability registration, and implementations |
| `rpc.go` | Discord gateway communication and RPC logic |
| `go.mod` | Go module file |
| File | Description |
|-----------|------------------------------------------------------------------|
| `main.go` | Plugin entry point, capability registration, and implementations |
| `rpc.go` | Discord gateway communication and RPC logic |
| `go.mod` | Go module file |
## PDK

View File

@ -52,8 +52,8 @@ func init() {
metadata.Register(&myPlugin{})
}
func (p *myPlugin) GetArtistBiography(input metadata.ArtistInput) (metadata.ArtistBiographyOutput, error) {
return metadata.ArtistBiographyOutput{Biography: "..."}, nil
func (p *myPlugin) GetArtistBiography(input metadata.ArtistRequest) (metadata.ArtistBiographyResponse, error) {
return metadata.ArtistBiographyResponse{Biography: "..."}, nil
}
```