agents

package
v0.52.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

README

This folder abstracts metadata lookup into "agents". Each agent can be implemented to get as much info as the external source provides, by using a granular set of interfaces (see interfaces).

A new agent must comply with these simple implementation rules:

  1. Implement the AgentName() method. It just returns the name of the agent for logging purposes.
  2. Implement one or more of the *Retriever() interfaces. That's where the agent's logic resides.
  3. Register itself (in its init() function).

For an agent to be used it needs to be listed in the Agents config option (default is "lastfm,spotify"). The order dictates the priority of the agents

For a simple Agent example, look at the local_agent agent source code.

Documentation

Index

Constants

View Source
const LocalAgentName = "local"

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func Register

func Register(name string, init Constructor)

Types

type Agents added in v0.44.0

type Agents struct {
	// contains filtered or unexported fields
}

func New added in v0.44.0

func New(ds model.DataStore) *Agents

func (*Agents) AgentName added in v0.44.0

func (a *Agents) AgentName() string

func (*Agents) GetAlbumInfo added in v0.49.0

func (a *Agents) GetAlbumInfo(ctx context.Context, name, artist, mbid string) (*AlbumInfo, error)

func (*Agents) GetArtistBiography added in v0.49.0

func (a *Agents) GetArtistBiography(ctx context.Context, id, name, mbid string) (string, error)

func (*Agents) GetArtistImages added in v0.49.0

func (a *Agents) GetArtistImages(ctx context.Context, id, name, mbid string) ([]ExternalImage, error)

func (*Agents) GetArtistMBID added in v0.49.0

func (a *Agents) GetArtistMBID(ctx context.Context, id string, name string) (string, error)

func (*Agents) GetArtistTopSongs added in v0.49.0

func (a *Agents) GetArtistTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error)

func (*Agents) GetArtistURL added in v0.49.0

func (a *Agents) GetArtistURL(ctx context.Context, id, name, mbid string) (string, error)

func (*Agents) GetSimilarArtists added in v0.49.0

func (a *Agents) GetSimilarArtists(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error)

type AlbumInfo added in v0.49.0

type AlbumInfo struct {
	Name        string
	MBID        string
	Description string
	URL         string
	Images      []ExternalImage
}

type AlbumInfoRetriever added in v0.49.0

type AlbumInfoRetriever interface {
	GetAlbumInfo(ctx context.Context, name, artist, mbid string) (*AlbumInfo, error)
}

TODO Break up this interface in more specific methods, like artists

type Artist

type Artist struct {
	Name string
	MBID string
}

type ArtistBiographyRetriever

type ArtistBiographyRetriever interface {
	GetArtistBiography(ctx context.Context, id, name, mbid string) (string, error)
}

type ArtistImageRetriever

type ArtistImageRetriever interface {
	GetArtistImages(ctx context.Context, id, name, mbid string) ([]ExternalImage, error)
}

type ArtistMBIDRetriever

type ArtistMBIDRetriever interface {
	GetArtistMBID(ctx context.Context, id string, name string) (string, error)
}

type ArtistSimilarRetriever

type ArtistSimilarRetriever interface {
	GetSimilarArtists(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error)
}

type ArtistTopSongsRetriever

type ArtistTopSongsRetriever interface {
	GetArtistTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error)
}

type ArtistURLRetriever

type ArtistURLRetriever interface {
	GetArtistURL(ctx context.Context, id, name, mbid string) (string, error)
}

type Constructor

type Constructor func(ds model.DataStore) Interface

type ExternalImage added in v0.49.0

type ExternalImage struct {
	URL  string
	Size int
}

type Interface

type Interface interface {
	AgentName() string
}

type SessionKeys added in v0.47.0

type SessionKeys struct {
	model.DataStore
	KeyName string
}

SessionKeys is a simple wrapper around the UserPropsRepository

func (*SessionKeys) Delete added in v0.47.0

func (sk *SessionKeys) Delete(ctx context.Context, userId string) error

func (*SessionKeys) Get added in v0.47.0

func (sk *SessionKeys) Get(ctx context.Context, userId string) (string, error)

func (*SessionKeys) Put added in v0.47.0

func (sk *SessionKeys) Put(ctx context.Context, userId, sessionKey string) error

type Song

type Song struct {
	Name string
	MBID string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL