mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-14 11:17:19 +03:00
Add artist ID to agent's interfaces
This commit is contained in:
parent
501af14186
commit
b855fe865e
@ -31,27 +31,27 @@ var (
|
||||
)
|
||||
|
||||
type ArtistMBIDRetriever interface {
|
||||
GetMBID(name string) (string, error)
|
||||
GetMBID(id string, name string) (string, error)
|
||||
}
|
||||
|
||||
type ArtistURLRetriever interface {
|
||||
GetURL(name, mbid string) (string, error)
|
||||
GetURL(id, name, mbid string) (string, error)
|
||||
}
|
||||
|
||||
type ArtistBiographyRetriever interface {
|
||||
GetBiography(name, mbid string) (string, error)
|
||||
GetBiography(id, name, mbid string) (string, error)
|
||||
}
|
||||
|
||||
type ArtistSimilarRetriever interface {
|
||||
GetSimilar(name, mbid string, limit int) ([]Artist, error)
|
||||
GetSimilar(id, name, mbid string, limit int) ([]Artist, error)
|
||||
}
|
||||
|
||||
type ArtistImageRetriever interface {
|
||||
GetImages(name, mbid string) ([]ArtistImage, error)
|
||||
GetImages(id, name, mbid string) ([]ArtistImage, error)
|
||||
}
|
||||
|
||||
type ArtistTopSongsRetriever interface {
|
||||
GetTopSongs(artistName, mbid string, count int) ([]Song, error)
|
||||
GetTopSongs(id, artistName, mbid string, count int) ([]Song, error)
|
||||
}
|
||||
|
||||
var Map map[string]Constructor
|
||||
|
@ -34,7 +34,7 @@ func (l *lastfmAgent) AgentName() string {
|
||||
return lastFMAgentName
|
||||
}
|
||||
|
||||
func (l *lastfmAgent) GetMBID(name string) (string, error) {
|
||||
func (l *lastfmAgent) GetMBID(id string, name string) (string, error) {
|
||||
a, err := l.callArtistGetInfo(name, "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -45,7 +45,7 @@ func (l *lastfmAgent) GetMBID(name string) (string, error) {
|
||||
return a.MBID, nil
|
||||
}
|
||||
|
||||
func (l *lastfmAgent) GetURL(name, mbid string) (string, error) {
|
||||
func (l *lastfmAgent) GetURL(id, name, mbid string) (string, error) {
|
||||
a, err := l.callArtistGetInfo(name, mbid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -56,7 +56,7 @@ func (l *lastfmAgent) GetURL(name, mbid string) (string, error) {
|
||||
return a.URL, nil
|
||||
}
|
||||
|
||||
func (l *lastfmAgent) GetBiography(name, mbid string) (string, error) {
|
||||
func (l *lastfmAgent) GetBiography(id, name, mbid string) (string, error) {
|
||||
a, err := l.callArtistGetInfo(name, mbid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -67,7 +67,7 @@ func (l *lastfmAgent) GetBiography(name, mbid string) (string, error) {
|
||||
return a.Bio.Summary, nil
|
||||
}
|
||||
|
||||
func (l *lastfmAgent) GetSimilar(name, mbid string, limit int) ([]Artist, error) {
|
||||
func (l *lastfmAgent) GetSimilar(id, name, mbid string, limit int) ([]Artist, error) {
|
||||
resp, err := l.callArtistGetSimilar(name, mbid, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -85,7 +85,7 @@ func (l *lastfmAgent) GetSimilar(name, mbid string, limit int) ([]Artist, error)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (l *lastfmAgent) GetTopSongs(artistName, mbid string, count int) ([]Song, error) {
|
||||
func (l *lastfmAgent) GetTopSongs(id, artistName, mbid string, count int) ([]Song, error) {
|
||||
resp, err := l.callArtistGetTopTracks(artistName, mbid, count)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -23,11 +23,11 @@ func (p *placeholderAgent) AgentName() string {
|
||||
return PlaceholderAgentName
|
||||
}
|
||||
|
||||
func (p *placeholderAgent) GetBiography(name, mbid string) (string, error) {
|
||||
func (p *placeholderAgent) GetBiography(id, name, mbid string) (string, error) {
|
||||
return placeholderBiography, nil
|
||||
}
|
||||
|
||||
func (p *placeholderAgent) GetImages(name, mbid string) ([]ArtistImage, error) {
|
||||
func (p *placeholderAgent) GetImages(id, name, mbid string) ([]ArtistImage, error) {
|
||||
return []ArtistImage{
|
||||
{placeholderArtistImageLargeUrl, 300},
|
||||
{placeholderArtistImageMediumUrl, 174},
|
||||
|
@ -39,7 +39,7 @@ func (s *spotifyAgent) AgentName() string {
|
||||
return spotifyAgentName
|
||||
}
|
||||
|
||||
func (s *spotifyAgent) GetImages(name, mbid string) ([]ArtistImage, error) {
|
||||
func (s *spotifyAgent) GetImages(id, name, mbid string) ([]ArtistImage, error) {
|
||||
a, err := s.searchArtist(name)
|
||||
if err != nil {
|
||||
if err == model.ErrNotFound {
|
||||
|
@ -243,7 +243,7 @@ func (e *externalInfo) callGetMBID(ctx context.Context, allAgents []agents.Inter
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
mbid, err := agent.GetMBID(artist.Name)
|
||||
mbid, err := agent.GetMBID(artist.ID, artist.Name)
|
||||
if mbid != "" && err == nil {
|
||||
artist.MbzArtistID = mbid
|
||||
log.Debug(ctx, "Got MBID", "agent", a.AgentName(), "artist", artist.Name, "mbid", mbid, "elapsed", time.Since(start))
|
||||
@ -263,7 +263,7 @@ func (e *externalInfo) callGetTopSongs(ctx context.Context, allAgents []agents.I
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
songs, err := agent.GetTopSongs(artist.Name, artist.MbzArtistID, count)
|
||||
songs, err := agent.GetTopSongs(artist.ID, artist.Name, artist.MbzArtistID, count)
|
||||
if len(songs) > 0 && err == nil {
|
||||
log.Debug(ctx, "Got Top Songs", "agent", a.AgentName(), "artist", artist.Name, "songs", songs, "elapsed", time.Since(start))
|
||||
return songs, err
|
||||
@ -285,7 +285,7 @@ func (e *externalInfo) callGetURL(ctx context.Context, allAgents []agents.Interf
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
url, err := agent.GetURL(artist.Name, artist.MbzArtistID)
|
||||
url, err := agent.GetURL(artist.ID, artist.Name, artist.MbzArtistID)
|
||||
if url != "" && err == nil {
|
||||
artist.ExternalUrl = url
|
||||
log.Debug(ctx, "Got External Url", "agent", a.AgentName(), "artist", artist.Name, "url", url, "elapsed", time.Since(start))
|
||||
@ -308,7 +308,7 @@ func (e *externalInfo) callGetBiography(ctx context.Context, allAgents []agents.
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
bio, err := agent.GetBiography(clearName(artist.Name), artist.MbzArtistID)
|
||||
bio, err := agent.GetBiography(artist.ID, clearName(artist.Name), artist.MbzArtistID)
|
||||
if bio != "" && err == nil {
|
||||
policy := bluemonday.UGCPolicy()
|
||||
bio = policy.Sanitize(bio)
|
||||
@ -334,7 +334,7 @@ func (e *externalInfo) callGetImage(ctx context.Context, allAgents []agents.Inte
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
images, err := agent.GetImages(artist.Name, artist.MbzArtistID)
|
||||
images, err := agent.GetImages(artist.ID, artist.Name, artist.MbzArtistID)
|
||||
if len(images) == 0 || err != nil {
|
||||
continue
|
||||
}
|
||||
@ -367,7 +367,7 @@ func (e *externalInfo) callGetSimilar(ctx context.Context, allAgents []agents.In
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
similar, err := agent.GetSimilar(artist.Name, artist.MbzArtistID, limit)
|
||||
similar, err := agent.GetSimilar(artist.ID, artist.Name, artist.MbzArtistID, limit)
|
||||
if len(similar) == 0 || err != nil {
|
||||
continue
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user