navidrome/core/agents/interfaces.go

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

80 lines
1.6 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 AlbumInfo struct {
Name string
MBID string
Description string
URL string
Images []ExternalImage
}
2021-02-07 22:46:15 +01:00
type Artist struct {
Name string
MBID string
}
type ExternalImage struct {
2021-02-07 22:46:15 +01:00
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")
)
2023-01-19 15:34:39 +01:00
// TODO Break up this interface in more specific methods, like artists
type AlbumInfoRetriever interface {
GetAlbumInfo(ctx context.Context, name, artist, mbid string) (*AlbumInfo, error)
}
2021-02-07 22:46:15 +01:00
type ArtistMBIDRetriever interface {
GetArtistMBID(ctx context.Context, id string, name string) (string, error)
2021-02-07 22:46:15 +01:00
}
type ArtistURLRetriever interface {
GetArtistURL(ctx context.Context, id, name, mbid string) (string, error)
2021-02-07 22:46:15 +01:00
}
type ArtistBiographyRetriever interface {
GetArtistBiography(ctx context.Context, id, name, mbid string) (string, error)
2021-02-07 22:46:15 +01:00
}
type ArtistSimilarRetriever interface {
GetSimilarArtists(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error)
2021-02-07 22:46:15 +01:00
}
type ArtistImageRetriever interface {
GetArtistImages(ctx context.Context, id, name, mbid string) ([]ExternalImage, error)
2021-02-07 22:46:15 +01:00
}
type ArtistTopSongsRetriever interface {
GetArtistTopSongs(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
}