docs: update README to reflect usage of nd-pdk library
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Discord Rich Presence Plugin (Rust)
|
# Discord Rich Presence Plugin (Rust)
|
||||||
|
|
||||||
A Navidrome plugin that displays your currently playing track on Discord using Rich Presence. This is the Rust implementation demonstrating how to use the generated `nd-host` library.
|
A Navidrome plugin that displays your currently playing track on Discord using Rich Presence. This is the Rust implementation demonstrating how to use the `nd-pdk` library.
|
||||||
|
|
||||||
## ⚠️ Warning
|
## ⚠️ Warning
|
||||||
|
|
||||||
@@ -21,20 +21,20 @@ This plugin is for **demonstration purposes only**. It requires storing your Dis
|
|||||||
|
|
||||||
## Capabilities
|
## Capabilities
|
||||||
|
|
||||||
This plugin implements three capabilities to demonstrate the nd-host library:
|
This plugin implements multiple capabilities to demonstrate the nd-pdk library:
|
||||||
|
|
||||||
- **Scrobbler**: Receives now-playing events from Navidrome
|
- **Scrobbler**: Receives now-playing events from Navidrome
|
||||||
- **SchedulerCallback**: Handles heartbeat and activity clearing timers
|
- **SchedulerCallback**: Handles heartbeat and activity clearing timers
|
||||||
- **WebSocketCallback**: Communicates with Discord gateway
|
- **WebSocketCallback**: Communicates with Discord gateway (text, binary, error, and close handlers)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Configure in the Navidrome UI (Settings → Plugins → discord-rich-presence):
|
Configure in the Navidrome UI (Settings → Plugins → discord-rich-presence):
|
||||||
|
|
||||||
| Key | Description | Example |
|
| Key | Description | Example |
|
||||||
|---------------|-------------------------------------------|--------------------------------|
|
|---------------|--------------------------------------|---------------------------|
|
||||||
| `clientid` | Your Discord application ID | `123456789012345678` |
|
| `clientid` | Your Discord application ID | `123456789012345678` |
|
||||||
| `user.<name>` | Discord token for the specified user | `user.alice` = `token123` |
|
| `user.<name>` | Discord token for the specified user | `user.alice` = `token123` |
|
||||||
|
|
||||||
Each user is configured as a separate key with the `user.` prefix.
|
Each user is configured as a separate key with the `user.` prefix.
|
||||||
|
|
||||||
@@ -69,27 +69,30 @@ make discord-rich-presence-rs.ndp
|
|||||||
3. Enable and configure the plugin in the Navidrome UI (Settings → Plugins)
|
3. Enable and configure the plugin in the Navidrome UI (Settings → Plugins)
|
||||||
4. Restart Navidrome if needed
|
4. Restart Navidrome if needed
|
||||||
|
|
||||||
## Using nd-host Library
|
## Using nd-pdk Library
|
||||||
|
|
||||||
This plugin demonstrates how to use the generated Rust host function wrappers:
|
This plugin demonstrates how to use the Rust plugin development kit:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use nd_host::{artwork, cache, scheduler, websocket};
|
use nd_pdk::host::{artwork, cache, scheduler, websocket};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
// Get artwork URL
|
// Get artwork URL
|
||||||
let (url, _) = artwork::artwork_get_track_url(track_id, 300)?;
|
let url = artwork::get_track_url(track_id, 300)?;
|
||||||
|
|
||||||
// Cache operations
|
// Cache operations
|
||||||
cache::cache_set_string("key", "value", 3600)?;
|
cache::set_string("key", "value", 3600)?;
|
||||||
let (value, exists) = cache::cache_get_string("key")?;
|
if let Some(value) = cache::get_string("key")? {
|
||||||
|
// Use the cached value
|
||||||
|
}
|
||||||
|
|
||||||
// Schedule tasks
|
// Schedule tasks
|
||||||
scheduler::scheduler_schedule_one_time(60, "payload", "task-id")?;
|
scheduler::schedule_one_time(60, "payload", "task-id")?;
|
||||||
scheduler::scheduler_schedule_recurring("@every 30s", "heartbeat", "heartbeat-task")?;
|
scheduler::schedule_recurring("@every 30s", "heartbeat", "heartbeat-task")?;
|
||||||
|
|
||||||
// WebSocket operations
|
// WebSocket operations
|
||||||
let conn_id = websocket::websocket_connect("wss://example.com/socket")?;
|
let conn_id = websocket::connect("wss://example.com/socket", HashMap::new(), "my-conn")?;
|
||||||
websocket::websocket_send_text(&conn_id, "Hello")?;
|
websocket::send_text(&conn_id, "Hello")?;
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
Reference in New Issue
Block a user