Add album aliases support to MusicBrainz

This commit is contained in:
DataHoarder 2022-02-16 12:14:54 +01:00
parent d37e263e89
commit bc5e87d095

View file

@ -161,16 +161,13 @@ type eventEntry struct {
Disambiguation string `json:"disambiguation"`
}
type artistEntry struct {
Id string `json:"id"`
Name string `json:"name"`
SortName string `json:"sort-name"`
Disambiguation string `json:"disambiguation"`
Type string `json:"type"`
Rating ratingEntry `json:"rating"`
Aliases []struct {
Name string `json:"name"`
SortName string `json:"sort-name"`
} `json:"aliases"`
Id string `json:"id"`
Name string `json:"name"`
SortName string `json:"sort-name"`
Disambiguation string `json:"disambiguation"`
Type string `json:"type"`
Rating ratingEntry `json:"rating"`
Aliases []aliasEntry `json:"aliases"`
}
type artistCreditEntry struct {
Name string `json:"name"`
@ -202,6 +199,7 @@ type recordingEntry struct {
Relations []relationEntry `json:"relations"`
ISRCS []string `json:"isrcs"`
ArtistCredit []artistCreditEntry `json:"artist-credit"`
//TODO Aliases
}
type trackEntry struct {
@ -230,6 +228,12 @@ type mediaEntry struct {
Title string `json:"title"`
}
type aliasEntry struct {
Type string `json:"type"`
Name string `json:"name"`
SortName string `json:"sort-name"`
}
type labelEntry struct {
Id string `json:"id"`
Tags []tagEntry `json:"tags"`
@ -382,6 +386,7 @@ func (s *Source) GetRelease(releaseId string) *metadata.Album {
Date string `json:"date"`
Media []mediaEntry `json:"media"`
Title string `json:"title"`
Aliases []aliasEntry `json:"aliases"`
Status string `json:"status"`
Id string `json:"id"`
Barcode string `json:"barcode"`
@ -407,6 +412,15 @@ func (s *Source) GetRelease(releaseId string) *metadata.Album {
},
}
for _, n := range release.Aliases {
if n.Type == "Release name" {
album.Name = append(album.Name, metadata.Name{Kind: "original", Name: n.Name})
if n.SortName != n.Name {
album.Name = append(album.Name, metadata.Name{Kind: "sort", Name: n.SortName})
}
}
}
if release.CoverArtArchive.Count > 0 {
album.Art = s.GetReleaseCoverArt(release.Id)
}