feat(participants): add DisplayName method to prioritize CreditedAs over Name

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2026-05-24 20:01:45 -03:00
parent a859804fd4
commit 03b8b15f6e
2 changed files with 6 additions and 11 deletions

View File

@ -81,6 +81,10 @@ type Participant struct {
CreditedAs string `json:"creditedAs,omitempty"`
}
func (p Participant) DisplayName() string {
return cmp.Or(p.CreditedAs, p.Name)
}
type ParticipantList []Participant
func (p ParticipantList) Join(sep string) string {

View File

@ -282,7 +282,7 @@ func osChildFromMediaFile(ctx context.Context, mf model.MediaFile) *responses.Op
SubRole: participant.SubRole,
Artist: responses.ArtistID3Ref{
Id: participant.ID,
Name: participantDisplayName(participant),
Name: participant.DisplayName(),
},
})
}
@ -296,20 +296,11 @@ func artistRefs(participants model.ParticipantList) []responses.ArtistID3Ref {
return slice.Map(participants, func(p model.Participant) responses.ArtistID3Ref {
return responses.ArtistID3Ref{
Id: p.ID,
Name: participantDisplayName(p),
Name: p.DisplayName(),
}
})
}
// participantDisplayName returns CreditedAs if set, otherwise the canonical Name.
// Legacy rows (pre-rescan) have empty CreditedAs and continue to show canonical.
func participantDisplayName(p model.Participant) string {
if p.CreditedAs != "" {
return p.CreditedAs
}
return p.Name
}
func fakePath(mf model.MediaFile) string {
builder := strings.Builder{}