772d1f359b
* refactor: rename ArtistRadio to SimilarSongs for clarity and consistency Signed-off-by: Deluan <deluan@navidrome.org> * feat: implement GetSimilarSongsByTrack and related functionality for song similarity retrieval Signed-off-by: Deluan <deluan@navidrome.org> * feat: enhance GetSimilarSongsByTrack to include artist and album details and update tests Signed-off-by: Deluan <deluan@navidrome.org> * feat: enhance song matching by implementing title and artist filtering in loadTracksByTitleAndArtist Signed-off-by: Deluan <deluan@navidrome.org> * test: add unit tests for song matching functionality in provider Signed-off-by: Deluan <deluan@navidrome.org> * refactor: extract song matching functionality into its own file Signed-off-by: Deluan <deluan@navidrome.org> * docs: clarify similarSongsFallback function description in provider.go Signed-off-by: Deluan <deluan@navidrome.org> * refactor: initialize result slice for songs with capacity based on response length Signed-off-by: Deluan <deluan@navidrome.org> * refactor: simplify agent method calls for retrieving images and similar songs Signed-off-by: Deluan <deluan@navidrome.org> * refactor: simplify agent method calls for retrieving images and similar songs Signed-off-by: Deluan <deluan@navidrome.org> * refactor: remove outdated comments in GetSimilarSongs methods Signed-off-by: Deluan <deluan@navidrome.org> * fix: use composite key for song matches to handle duplicates by title and artist Signed-off-by: Deluan <deluan@navidrome.org> * refactor: consolidate expectations setup for similar songs tests Signed-off-by: Deluan <deluan@navidrome.org> * feat: add instant mix action to song context menu and update translations Signed-off-by: Deluan <deluan@navidrome.org> * fix(provider): handle unknown entity types in GetSimilarSongs Signed-off-by: Deluan <deluan@navidrome.org> * refactor: move playSimilar action to playbackActions and streamline song processing Signed-off-by: Deluan <deluan@navidrome.org> * format Signed-off-by: Deluan <deluan@navidrome.org> * feat: enhance instant mix functionality with loading notification and shuffle option Signed-off-by: Deluan <deluan@navidrome.org> * feat: implement fuzzy matching for similar songs based on configurable threshold Signed-off-by: Deluan <deluan@navidrome.org> * refactor: implement track matching with multiple specificity levels Signed-off-by: Deluan <deluan@navidrome.org> * refactor: enhance track matching by implementing unified scoring with specificity levels Signed-off-by: Deluan <deluan@navidrome.org> * feat: enhance deezer top tracks result with album Signed-off-by: Deluan <deluan@navidrome.org> * feat: enhance track matching with fuzzy album similarity for improved scoring Signed-off-by: Deluan <deluan@navidrome.org> * docs: document multi-phase song matching algorithm with detailed scoring and prioritization Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
126 lines
3.3 KiB
Go
126 lines
3.3 KiB
Go
package agents
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/navidrome/navidrome/model"
|
|
)
|
|
|
|
type Constructor func(ds model.DataStore) Interface
|
|
|
|
type Interface interface {
|
|
AgentName() string
|
|
}
|
|
|
|
// AlbumInfo contains album metadata (no images)
|
|
type AlbumInfo struct {
|
|
Name string
|
|
MBID string
|
|
Description string
|
|
URL string
|
|
}
|
|
|
|
type Artist struct {
|
|
ID string
|
|
Name string
|
|
MBID string
|
|
}
|
|
|
|
type ExternalImage struct {
|
|
URL string
|
|
Size int
|
|
}
|
|
|
|
type Song struct {
|
|
ID string
|
|
Name string
|
|
MBID string
|
|
Artist string
|
|
ArtistMBID string
|
|
Album string
|
|
AlbumMBID string
|
|
}
|
|
|
|
var (
|
|
ErrNotFound = errors.New("not found")
|
|
)
|
|
|
|
// AlbumInfoRetriever provides album info (no images)
|
|
type AlbumInfoRetriever interface {
|
|
GetAlbumInfo(ctx context.Context, name, artist, mbid string) (*AlbumInfo, error)
|
|
}
|
|
|
|
// AlbumImageRetriever provides album images
|
|
type AlbumImageRetriever interface {
|
|
GetAlbumImages(ctx context.Context, name, artist, mbid string) ([]ExternalImage, error)
|
|
}
|
|
|
|
type ArtistMBIDRetriever interface {
|
|
GetArtistMBID(ctx context.Context, id string, name string) (string, error)
|
|
}
|
|
|
|
type ArtistURLRetriever interface {
|
|
GetArtistURL(ctx context.Context, id, name, mbid string) (string, error)
|
|
}
|
|
|
|
type ArtistBiographyRetriever interface {
|
|
GetArtistBiography(ctx context.Context, id, name, mbid string) (string, error)
|
|
}
|
|
|
|
type ArtistSimilarRetriever interface {
|
|
GetSimilarArtists(ctx context.Context, id, name, mbid string, limit int) ([]Artist, error)
|
|
}
|
|
|
|
type ArtistImageRetriever interface {
|
|
GetArtistImages(ctx context.Context, id, name, mbid string) ([]ExternalImage, error)
|
|
}
|
|
|
|
type ArtistTopSongsRetriever interface {
|
|
GetArtistTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error)
|
|
}
|
|
|
|
// SimilarSongsByTrackRetriever provides similar songs based on a specific track
|
|
type SimilarSongsByTrackRetriever interface {
|
|
// GetSimilarSongsByTrack returns songs similar to the given track.
|
|
// Parameters:
|
|
// - id: local mediafile ID
|
|
// - name: track title
|
|
// - artist: artist name
|
|
// - mbid: MusicBrainz recording ID (may be empty)
|
|
// - count: maximum number of results
|
|
GetSimilarSongsByTrack(ctx context.Context, id, name, artist, mbid string, count int) ([]Song, error)
|
|
}
|
|
|
|
// SimilarSongsByAlbumRetriever provides similar songs based on an album
|
|
type SimilarSongsByAlbumRetriever interface {
|
|
// GetSimilarSongsByAlbum returns songs similar to tracks on the given album.
|
|
// Parameters:
|
|
// - id: local album ID
|
|
// - name: album name
|
|
// - artist: album artist name
|
|
// - mbid: MusicBrainz release ID (may be empty)
|
|
// - count: maximum number of results
|
|
GetSimilarSongsByAlbum(ctx context.Context, id, name, artist, mbid string, count int) ([]Song, error)
|
|
}
|
|
|
|
// SimilarSongsByArtistRetriever provides similar songs based on an artist
|
|
type SimilarSongsByArtistRetriever interface {
|
|
// GetSimilarSongsByArtist returns songs similar to the artist's catalog.
|
|
// Parameters:
|
|
// - id: local artist ID
|
|
// - name: artist name
|
|
// - mbid: MusicBrainz artist ID (may be empty)
|
|
// - count: maximum number of results
|
|
GetSimilarSongsByArtist(ctx context.Context, id, name, mbid string, count int) ([]Song, error)
|
|
}
|
|
|
|
var Map map[string]Constructor
|
|
|
|
func Register(name string, init Constructor) {
|
|
if Map == nil {
|
|
Map = make(map[string]Constructor)
|
|
}
|
|
Map[name] = init
|
|
}
|