Don't retrieve Various Artists and Unknown Artist info from Last.fm

This commit is contained in:
Deluan
2023-02-04 21:18:51 -05:00
parent a50d9c8b67
commit 3ce3185118
6 changed files with 82 additions and 11 deletions
+12
View File
@@ -6,6 +6,7 @@ import (
"net/http"
"regexp"
"strconv"
"strings"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/consts"
@@ -21,6 +22,11 @@ const (
sessionKeyProperty = "LastFMSessionKey"
)
var ignoredBiographies = []string{
// Unknown Artist
`<a href="https://www.last.fm/music/`,
}
type lastfmAgent struct {
ds model.DataStore
sessionKeys *agents.SessionKeys
@@ -124,9 +130,15 @@ func (l *lastfmAgent) GetArtistBiography(ctx context.Context, id, name, mbid str
if err != nil {
return "", err
}
a.Bio.Summary = strings.TrimSpace(a.Bio.Summary)
if a.Bio.Summary == "" {
return "", agents.ErrNotFound
}
for _, ign := range ignoredBiographies {
if strings.HasPrefix(a.Bio.Summary, ign) {
return "", nil
}
}
return a.Bio.Summary, nil
}