Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled
83 lines
2.5 KiB
Go
83 lines
2.5 KiB
Go
//go:build wasip1
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/navidrome/navidrome/plugins/api"
|
|
)
|
|
|
|
type FakeArtistAgent struct{}
|
|
|
|
var ErrNotFound = api.ErrNotFound
|
|
|
|
func (FakeArtistAgent) GetArtistMBID(ctx context.Context, req *api.ArtistMBIDRequest) (*api.ArtistMBIDResponse, error) {
|
|
if req.Name != "" {
|
|
return &api.ArtistMBIDResponse{Mbid: "1234567890"}, nil
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|
|
func (FakeArtistAgent) GetArtistURL(ctx context.Context, req *api.ArtistURLRequest) (*api.ArtistURLResponse, error) {
|
|
if req.Name != "" {
|
|
return &api.ArtistURLResponse{Url: "https://example.com"}, nil
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|
|
func (FakeArtistAgent) GetArtistBiography(ctx context.Context, req *api.ArtistBiographyRequest) (*api.ArtistBiographyResponse, error) {
|
|
if req.Name != "" {
|
|
return &api.ArtistBiographyResponse{Biography: "This is a test biography"}, nil
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|
|
func (FakeArtistAgent) GetSimilarArtists(ctx context.Context, req *api.ArtistSimilarRequest) (*api.ArtistSimilarResponse, error) {
|
|
if req.Name != "" {
|
|
return &api.ArtistSimilarResponse{
|
|
Artists: []*api.Artist{
|
|
{Name: "Similar Artist 1", Mbid: "mbid1"},
|
|
{Name: "Similar Artist 2", Mbid: "mbid2"},
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|
|
func (FakeArtistAgent) GetArtistImages(ctx context.Context, req *api.ArtistImageRequest) (*api.ArtistImageResponse, error) {
|
|
if req.Name != "" {
|
|
return &api.ArtistImageResponse{
|
|
Images: []*api.ExternalImage{
|
|
{Url: "https://example.com/image1.jpg", Size: 100},
|
|
{Url: "https://example.com/image2.jpg", Size: 200},
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|
|
func (FakeArtistAgent) GetArtistTopSongs(ctx context.Context, req *api.ArtistTopSongsRequest) (*api.ArtistTopSongsResponse, error) {
|
|
if req.ArtistName != "" {
|
|
return &api.ArtistTopSongsResponse{
|
|
Songs: []*api.Song{
|
|
{Name: "Song 1", Mbid: "mbid1"},
|
|
{Name: "Song 2", Mbid: "mbid2"},
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|
|
|
|
// Add empty implementations for the album methods to satisfy the MetadataAgent interface
|
|
func (FakeArtistAgent) GetAlbumInfo(ctx context.Context, req *api.AlbumInfoRequest) (*api.AlbumInfoResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
func (FakeArtistAgent) GetAlbumImages(ctx context.Context, req *api.AlbumImagesRequest) (*api.AlbumImagesResponse, error) {
|
|
return nil, api.ErrNotImplemented
|
|
}
|
|
|
|
// main is required by Go WASI build
|
|
func main() {}
|
|
|
|
// init is used by go-plugin to register the implementation
|
|
func init() {
|
|
api.RegisterMetadataAgent(FakeArtistAgent{})
|
|
}
|