fix: multivalue tags
This commit is contained in:
@@ -64,10 +64,8 @@ var canonicalMap = map[string]string{
|
||||
var ffmpegKey = map[string]string{
|
||||
"Title": "title",
|
||||
"Artist": "artist",
|
||||
"Artists": "artist",
|
||||
"Album": "album",
|
||||
"AlbumArtist": "album_artist",
|
||||
"AlbumArtists": "album_artist",
|
||||
"Composer": "composer",
|
||||
"Track": "track",
|
||||
"TrackNumber": "track",
|
||||
@@ -80,12 +78,22 @@ var ffmpegKey = map[string]string{
|
||||
"Lyrics": "lyrics",
|
||||
}
|
||||
|
||||
// ffmpegMultiKey maps multi-valued canonical names to ffmpeg/Vorbis keys.
|
||||
// For FLAC/Vorbis, use uppercase ARTISTS/ALBUMARTISTS for proper multi-value support.
|
||||
var ffmpegMultiKey = map[string]string{
|
||||
"Artists": "ARTISTS",
|
||||
"AlbumArtists": "ALBUMARTISTS",
|
||||
}
|
||||
|
||||
// allowedCanonicals is the set of canonical tags we accept for writes.
|
||||
var allowedCanonicals = func() map[string]struct{} {
|
||||
m := make(map[string]struct{}, len(ffmpegKey))
|
||||
m := make(map[string]struct{}, len(ffmpegKey)+len(ffmpegMultiKey))
|
||||
for k := range ffmpegKey {
|
||||
m[k] = struct{}{}
|
||||
}
|
||||
for k := range ffmpegMultiKey {
|
||||
m[k] = struct{}{}
|
||||
}
|
||||
return m
|
||||
}()
|
||||
|
||||
@@ -132,6 +140,7 @@ func normalizeAndMapToFFmpeg(in map[string]string) map[string]string {
|
||||
return out
|
||||
}
|
||||
// normalizeMultiToFFmpeg maps multi-valued canonical keys to ffmpeg keys, preserving arrays.
|
||||
// Uses ffmpegMultiKey for proper Vorbis comment names (ARTISTS, ALBUMARTISTS).
|
||||
func normalizeMultiToFFmpeg(in map[string][]string) map[string][]string {
|
||||
out := map[string][]string{}
|
||||
for k, arr := range in {
|
||||
@@ -145,9 +154,14 @@ func normalizeMultiToFFmpeg(in map[string][]string) map[string][]string {
|
||||
continue
|
||||
}
|
||||
}
|
||||
ffk, ok := ffmpegKey[canonical]
|
||||
// First check if this is a multi-valued tag
|
||||
ffk, ok := ffmpegMultiKey[canonical]
|
||||
if !ok {
|
||||
continue
|
||||
// Fall back to regular ffmpeg key
|
||||
ffk, ok = ffmpegKey[canonical]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
vals := []string{}
|
||||
for _, v := range arr {
|
||||
|
||||
Reference in New Issue
Block a user