mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-15 22:07:08 +02:00
refactor(plugins): rename PlaylistGenerator to PlaylistProvider
Rename the capability from PlaylistGenerator to PlaylistProvider and the internal orchestrator struct from playlistGeneratorOrchestrator to playlistSyncer. The new names better describe what the capability does (provides playlists) rather than how it works internally. All source files, test plugin, PDK packages (Go/Rust), YAML schemas, and exported WASM function names are updated accordingly.
This commit is contained in:
parent
03a36c5bdd
commit
04aa10f988
15 changed files with 150 additions and 150 deletions
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"name": "Test Playlist Generator",
|
||||
"author": "Navidrome Test",
|
||||
"version": "1.0.0",
|
||||
"description": "A test playlist generator plugin for integration testing"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module test-playlist-generator
|
||||
module test-playlist-provider
|
||||
|
||||
go 1.25
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Test playlist generator plugin for Navidrome plugin system integration tests.
|
||||
// Test playlist provider plugin for Navidrome plugin system integration tests.
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
@ -6,20 +6,20 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/navidrome/navidrome/plugins/pdk/go/pdk"
|
||||
pg "github.com/navidrome/navidrome/plugins/pdk/go/playlistgenerator"
|
||||
pp "github.com/navidrome/navidrome/plugins/pdk/go/playlistprovider"
|
||||
)
|
||||
|
||||
func init() {
|
||||
pg.Register(&testPlaylistGenerator{})
|
||||
pp.Register(&testPlaylistProvider{})
|
||||
}
|
||||
|
||||
type testPlaylistGenerator struct{}
|
||||
type testPlaylistProvider struct{}
|
||||
|
||||
func (t *testPlaylistGenerator) GetAvailablePlaylists(_ pg.GetAvailablePlaylistsRequest) (pg.GetAvailablePlaylistsResponse, error) {
|
||||
func (t *testPlaylistProvider) GetAvailablePlaylists(_ pp.GetAvailablePlaylistsRequest) (pp.GetAvailablePlaylistsResponse, error) {
|
||||
// Check for configured error
|
||||
errMsg, hasErr := pdk.GetConfig("error")
|
||||
if hasErr && errMsg != "" {
|
||||
return pg.GetAvailablePlaylistsResponse{}, fmt.Errorf("%s", errMsg)
|
||||
return pp.GetAvailablePlaylistsResponse{}, fmt.Errorf("%s", errMsg)
|
||||
}
|
||||
|
||||
// Get the owner username from config (defaults to "admin")
|
||||
|
|
@ -28,8 +28,8 @@ func (t *testPlaylistGenerator) GetAvailablePlaylists(_ pg.GetAvailablePlaylists
|
|||
ownerUsername = u
|
||||
}
|
||||
|
||||
resp := pg.GetAvailablePlaylistsResponse{
|
||||
Playlists: []pg.PlaylistInfo{
|
||||
resp := pp.GetAvailablePlaylistsResponse{
|
||||
Playlists: []pp.PlaylistInfo{
|
||||
{ID: "daily-mix-1", OwnerUsername: ownerUsername},
|
||||
{ID: "daily-mix-2", OwnerUsername: ownerUsername},
|
||||
},
|
||||
|
|
@ -46,40 +46,40 @@ func (t *testPlaylistGenerator) GetAvailablePlaylists(_ pg.GetAvailablePlaylists
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (t *testPlaylistGenerator) GetPlaylist(req pg.GetPlaylistRequest) (pg.GetPlaylistResponse, error) {
|
||||
func (t *testPlaylistProvider) GetPlaylist(req pp.GetPlaylistRequest) (pp.GetPlaylistResponse, error) {
|
||||
// Check for configured error
|
||||
errMsg, hasErr := pdk.GetConfig("get_playlist_error")
|
||||
if hasErr && errMsg != "" {
|
||||
// Check if the error should be typed (e.g., NotFound)
|
||||
errType, _ := pdk.GetConfig("get_playlist_error_type")
|
||||
if errType == pg.PlaylistGeneratorErrorNotFound.Error() {
|
||||
return pg.GetPlaylistResponse{}, fmt.Errorf("%w: %s", pg.PlaylistGeneratorErrorNotFound, errMsg)
|
||||
if errType == pp.PlaylistProviderErrorNotFound.Error() {
|
||||
return pp.GetPlaylistResponse{}, fmt.Errorf("%w: %s", pp.PlaylistProviderErrorNotFound, errMsg)
|
||||
}
|
||||
return pg.GetPlaylistResponse{}, fmt.Errorf("%s", errMsg)
|
||||
return pp.GetPlaylistResponse{}, fmt.Errorf("%s", errMsg)
|
||||
}
|
||||
|
||||
switch req.ID {
|
||||
case "daily-mix-1":
|
||||
return pg.GetPlaylistResponse{
|
||||
return pp.GetPlaylistResponse{
|
||||
Name: "Daily Mix 1",
|
||||
Description: "Your personalized daily mix",
|
||||
CoverArtURL: "https://example.com/cover1.jpg",
|
||||
Tracks: []pg.SongRef{
|
||||
Tracks: []pp.SongRef{
|
||||
{Name: "Song A", Artist: "Artist One"},
|
||||
{Name: "Song B", Artist: "Artist Two"},
|
||||
},
|
||||
ValidUntil: 0, // Static, no refresh
|
||||
}, nil
|
||||
case "daily-mix-2":
|
||||
return pg.GetPlaylistResponse{
|
||||
return pp.GetPlaylistResponse{
|
||||
Name: "Daily Mix 2",
|
||||
Tracks: []pg.SongRef{
|
||||
Tracks: []pp.SongRef{
|
||||
{Name: "Song C", Artist: "Artist Three"},
|
||||
},
|
||||
ValidUntil: 0,
|
||||
}, nil
|
||||
default:
|
||||
return pg.GetPlaylistResponse{}, fmt.Errorf("unknown playlist: %s", req.ID)
|
||||
return pp.GetPlaylistResponse{}, fmt.Errorf("unknown playlist: %s", req.ID)
|
||||
}
|
||||
}
|
||||
|
||||
6
plugins/testdata/test-playlist-provider/manifest.json
vendored
Normal file
6
plugins/testdata/test-playlist-provider/manifest.json
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "Test Playlist Provider",
|
||||
"author": "Navidrome Test",
|
||||
"version": "1.0.0",
|
||||
"description": "A test playlist provider plugin for integration testing"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue