Implement new Artist refresh
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -9,9 +8,6 @@ import (
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/fatih/structs"
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
)
|
||||
|
||||
func toSqlArgs(rec interface{}) (map[string]interface{}, error) {
|
||||
@@ -58,49 +54,3 @@ func (e existsCond) ToSql() (string, []interface{}, error) {
|
||||
}
|
||||
return sql, args, err
|
||||
}
|
||||
|
||||
func getMostFrequentMbzID(ctx context.Context, mbzIDs, entityName, name string) string {
|
||||
ids := strings.Fields(mbzIDs)
|
||||
if len(ids) == 0 {
|
||||
return ""
|
||||
}
|
||||
var topId string
|
||||
var topCount int
|
||||
idCounts := map[string]int{}
|
||||
|
||||
if len(ids) == 1 {
|
||||
topId = ids[0]
|
||||
} else {
|
||||
for _, id := range ids {
|
||||
c := idCounts[id] + 1
|
||||
idCounts[id] = c
|
||||
if c > topCount {
|
||||
topId = id
|
||||
topCount = c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(idCounts) > 1 && name != consts.VariousArtists {
|
||||
log.Warn(ctx, "Multiple MBIDs found for "+entityName, "name", name, "mbids", idCounts, "selectedId", topId)
|
||||
}
|
||||
if topId == consts.VariousArtistsMbzId && name != consts.VariousArtists {
|
||||
log.Warn(ctx, "Artist with mbid of 'Various Artists'", "name", name, "mbid", topId)
|
||||
}
|
||||
|
||||
return topId
|
||||
}
|
||||
|
||||
func getGenres(genreIds string) model.Genres {
|
||||
ids := strings.Fields(genreIds)
|
||||
var genres model.Genres
|
||||
unique := map[string]struct{}{}
|
||||
for _, id := range ids {
|
||||
if _, ok := unique[id]; ok {
|
||||
continue
|
||||
}
|
||||
genres = append(genres, model.Genre{ID: id})
|
||||
unique[id] = struct{}{}
|
||||
}
|
||||
return genres
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user