use comma when joining artists

This commit is contained in:
sentriz
2023-09-10 16:48:06 +01:00
parent 07a7869836
commit ddd160545c
3 changed files with 6 additions and 15 deletions

View File

@@ -236,16 +236,16 @@ func (a *Album) GenreStrings() []string {
return strs
}
func (a *Album) ArtistsString() string {
func (a *Album) ArtistsStrings() []string {
var artists = append([]*Artist(nil), a.Artists...)
sort.Slice(artists, func(i, j int) bool {
return artists[i].ID < artists[j].ID
})
var names []string
strs := make([]string, 0, len(artists))
for _, artist := range artists {
names = append(names, artist.Name)
strs = append(strs, artist.Name)
}
return strings.Join(names, " & ")
return strs
}
type PlayQueue struct {

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"strconv"
"strings"
"time"
"github.com/google/uuid"
@@ -57,7 +58,7 @@ func (s *Scrobbler) Scrobble(user *db.User, track *db.Track, stamp time.Time, su
params.Add("track", track.TagTitle)
params.Add("trackNumber", strconv.Itoa(track.TagTrackNumber))
params.Add("album", track.Album.TagTitle)
params.Add("albumArtist", track.Album.ArtistsString())
params.Add("albumArtist", strings.Join(track.Album.ArtistsStrings(), ", "))
params.Add("duration", strconv.Itoa(track.Length))
// make sure we provide a valid uuid, since some users may have an incorrect mbid in their tags

View File

@@ -83,16 +83,6 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
})
ret.ArtistID = album.Artists[0].SID()
}
// replace tags that we're present
if ret.Title == "" {
ret.Title = "<title>"
}
if ret.Artist == "" {
ret.Artist = "<artist>"
}
if ret.Album == "" {
ret.Album = "<album>"
}
return ret
}