diff --git a/plugins/examples/README.md b/plugins/examples/README.md index 8b070585a..3b3a253cf 100644 --- a/plugins/examples/README.md +++ b/plugins/examples/README.md @@ -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 diff --git a/plugins/examples/discord-rich-presence/README.md b/plugins/examples/discord-rich-presence/README.md index 48488f198..34d7d74ac 100644 --- a/plugins/examples/discord-rich-presence/README.md +++ b/plugins/examples/discord-rich-presence/README.md @@ -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 diff --git a/plugins/examples/minimal/README.md b/plugins/examples/minimal/README.md index d0bd7a30a..549a98a8f 100644 --- a/plugins/examples/minimal/README.md +++ b/plugins/examples/minimal/README.md @@ -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 } ```