navidrome/core/agents/interfaces.go

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

67 lines
1.2 KiB
Go
Raw Normal View History

2021-02-07 22:46:15 +01:00
package agents
import (
"context"
"errors"
"github.com/navidrome/navidrome/model"
2021-02-07 22:46:15 +01:00
)
type Constructor func(ds model.DataStore) Interface
2021-02-07 22:46:15 +01:00
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
}
2021-02-08 21:53:07 +01:00
type Song struct {
2021-02-07 22:46:15 +01:00
Name string
MBID string
}
var (
ErrNotFound = errors.New("not found")
)
type ArtistMBIDRetriever interface {
GetMBID(ctx context.Context, id string, name string) (string, error)
2021-02-07 22:46:15 +01:00
}
type ArtistURLRetriever interface {
GetURL(ctx context.Context, id, name, mbid string) (string, error)
2021-02-07 22:46:15 +01:00
}
type ArtistBiographyRetriever interface {
GetBiography(ctx context.Context, id, name, mbid string) (string, error)
2021-02-07 22:46:15 +01:00
}
type ArtistSimilarRetriever interface {
GetSimilar(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error)
2021-02-07 22:46:15 +01:00
}
type ArtistImageRetriever interface {
GetImages(ctx context.Context, id, name, mbid string) ([]ArtistImage, error)
2021-02-07 22:46:15 +01:00
}
type ArtistTopSongsRetriever interface {
GetTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error)
2021-02-07 22:46:15 +01:00
}
var Map map[string]Constructor
func Register(name string, init Constructor) {
if Map == nil {
Map = make(map[string]Constructor)
}
Map[name] = init
}