Merge bb8dd57565f6c90928d4dd9381a1a8dbb5cc7378 into 58367afaea666c45e114956747f8da1a54e1261a

This commit is contained in:
Deluan Quintão 2025-04-11 10:34:06 +00:00 committed by GitHub
commit 053d4ce7b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 5 deletions

View File

@ -224,13 +224,38 @@ func (md Metadata) mapDisplayArtist() string {
}
func (md Metadata) mapDisplayAlbumArtist(mf model.MediaFile) string {
// 1. Check for explicit album artist tags first
albumArtistDisplay := md.mapDisplayName(model.TagAlbumArtist, model.TagAlbumArtists)
if albumArtistDisplay != "" {
return albumArtistDisplay
}
// 2. No explicit album artist, check for track artist tags
artistTag := model.TagTrackArtist
artistsTag := model.TagTrackArtists
hasMultiValuedArtistTag := len(md.tags[artistTag]) > 1 || len(md.tags[artistsTag]) > 1
hasSingleValuedArtistTag := len(md.tags[artistTag]) == 1 || len(md.tags[artistsTag]) == 1
if hasMultiValuedArtistTag {
// Special case from tests: Use only the first artist if ARTIST/ARTISTS tag is multi-valued
if len(md.tags[artistTag]) > 1 {
return md.tags[artistTag][0]
}
// We know artistsTag must have > 1 here
return md.tags[artistsTag][0]
}
// If execution reaches here, hasMultiValuedArtistTag is false
if hasSingleValuedArtistTag {
// For single artist values (including those with separators like ';'), use the artist display name
return md.mapDisplayArtist()
}
// 3. Neither album artist nor track artist tags found. Fallback logic:
fallbackName := consts.UnknownArtist
if md.Bool(model.TagCompilation) {
fallbackName = consts.VariousArtists
}
return cmp.Or(
md.mapDisplayName(model.TagAlbumArtist, model.TagAlbumArtists),
mf.Participants.First(model.RoleAlbumArtist).Name,
fallbackName,
)
// Use the name from the first participant found for RoleAlbumArtist, or the default fallback
return cmp.Or(mf.Participants.First(model.RoleAlbumArtist).Name, fallbackName)
}

View File

@ -505,6 +505,25 @@ var _ = Describe("Participants", func() {
Expect(albumArtist.MbzArtistID).To(Equal(mbid2))
})
})
Context("Multiple values in a single-valued ARTIST tag, no ALBUMARTIST tag", func() {
BeforeEach(func() {
mf = toMediaFile(model.RawTags{
"ARTIST": {"hey; ho"},
})
})
It("should use the full artist name as displayAlbumArtist when no ALBUMARTIST is provided", func() {
Expect(mf.AlbumArtist).To(Equal("hey; ho"))
participants := mf.Participants
Expect(participants).To(SatisfyAll(
HaveKeyWithValue(model.RoleAlbumArtist, HaveLen(2)),
))
albumArtist := participants[model.RoleAlbumArtist][0]
Expect(albumArtist.Name).To(Equal("hey"))
})
})
})
Describe("COMPOSER and LYRICIST tags (with sort names)", func() {