navidrome/core/agents/interfaces.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.0 KiB
Go
Raw Normal View History

2021-02-07 22:46:15 +01:00
package agents
import (
"context"
"errors"
)
type Constructor func(ctx context.Context) Interface
2021-02-08 16:14:29 +01:00
type Interface interface {
AgentName() string
}
2021-02-07 22:46:15 +01:00
type Artist struct {
Name string
MBID string
}
type ArtistImage struct {
URL string
Size int
}
type Track struct {
Name string
MBID string
}
var (
ErrNotFound = errors.New("not found")
)
type ArtistMBIDRetriever interface {
GetMBID(name string) (string, error)
}
type ArtistURLRetriever interface {
GetURL(name, mbid string) (string, error)
}
type ArtistBiographyRetriever interface {
GetBiography(name, mbid string) (string, error)
}
type ArtistSimilarRetriever interface {
GetSimilar(name, mbid string, limit int) ([]Artist, error)
}
type ArtistImageRetriever interface {
GetImages(name, mbid string) ([]ArtistImage, error)
}
type ArtistTopSongsRetriever interface {
GetTopSongs(artistName, mbid string, count int) ([]Track, error)
}
var Map map[string]Constructor
func Register(name string, init Constructor) {
if Map == nil {
Map = make(map[string]Constructor)
}
Map[name] = init
}