From 64531b717e850899217c105c390094a9ddb91bb8 Mon Sep 17 00:00:00 2001 From: majomi Date: Mon, 15 Jul 2024 16:18:59 +0200 Subject: [PATCH] fix vorbis multiple artists --- vorbis.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vorbis.go b/vorbis.go index f1c6a19..ce6ebe8 100644 --- a/vorbis.go +++ b/vorbis.go @@ -22,7 +22,7 @@ func newMetadataVorbis() *metadataVorbis { } type metadataVorbis struct { - c map[string]string // the vorbis comments + c map[string]string // the vorbis commentsq p *Picture } @@ -43,6 +43,8 @@ func (m *metadataVorbis) readVorbisComment(r io.Reader) error { return err } + artists := []string{} + for i := uint32(0); i < commentsLen; i++ { l, err := readUint32LittleEndian(r) if err != nil { @@ -56,9 +58,15 @@ func (m *metadataVorbis) readVorbisComment(r io.Reader) error { if err != nil { return err } + + if k == "ARTIST" { + artists = append(artists, v) + } m.c[strings.ToLower(k)] = v } + m.c["artist"] = strings.Join(artists, ";") + if b64data, ok := m.c["metadata_block_picture"]; ok { data, err := base64.StdEncoding.DecodeString(b64data) if err != nil { @@ -151,6 +159,7 @@ func parseComment(c string) (k, v string, err error) { err = errors.New("vorbis comment must contain '='") return } + k = kv[0] v = kv[1] return