mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-07-27 23:42:28 +02:00
feat: format multi-artist credits
This commit is contained in:
@@ -1358,6 +1358,7 @@ func buildTagMetadata(trackMeta map[string]any, title, source, trackID string, o
|
||||
if artist == "" {
|
||||
artist = jsonutil.NestedString(trackMeta, "artist", "name")
|
||||
}
|
||||
artistNames := stringSliceFromAny(trackMeta["artist_names"])
|
||||
albumArtist := jsonutil.NestedString(trackMeta, "album", "artist", "name")
|
||||
if albumArtist == "" {
|
||||
albumArtist = artist
|
||||
@@ -1469,6 +1470,7 @@ func buildTagMetadata(trackMeta map[string]any, title, source, trackID string, o
|
||||
Title: title,
|
||||
Album: album,
|
||||
Artist: artist,
|
||||
Artists: artistNames,
|
||||
AlbumArtist: albumArtist,
|
||||
OmitDiscTags: opts.forPlaylist,
|
||||
TrackNumber: trackNumber,
|
||||
@@ -1494,6 +1496,24 @@ func buildTagMetadata(trackMeta map[string]any, title, source, trackID string, o
|
||||
}
|
||||
}
|
||||
|
||||
func stringSliceFromAny(v any) []string {
|
||||
items, ok := v.([]string)
|
||||
if ok {
|
||||
return append([]string(nil), items...)
|
||||
}
|
||||
rawItems, ok := v.([]any)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
out := make([]string, 0, len(rawItems))
|
||||
for _, raw := range rawItems {
|
||||
if s := strings.TrimSpace(jsonutil.StringFromAny(raw)); s != "" {
|
||||
out = append(out, s)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func normalizeInitialKey(in string) string {
|
||||
s := strings.TrimSpace(in)
|
||||
if s == "" {
|
||||
|
||||
Reference in New Issue
Block a user