mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-02 07:12:36 +00:00
feat(participants): add DisplayName method to prioritize CreditedAs over Name
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
a859804fd4
commit
03b8b15f6e
@ -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 {
|
||||
|
||||
@ -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{}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user