return album genres as a list of objects as per opensubsonic

https://github.com/opensubsonic/open-subsonic-api/pull/51
This commit is contained in:
sentriz
2023-09-28 20:30:02 +01:00
parent 51cf57400e
commit 6b322e4a1f
7 changed files with 25 additions and 21 deletions

View File

@@ -44,7 +44,7 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
ret.Genre = a.Genres[0].Name
}
for _, g := range a.Genres {
ret.Genres = append(ret.Genres, g.Name)
ret.Genres = append(ret.Genres, &GenreRef{Name: g.Name})
}
return ret
}

View File

@@ -116,6 +116,10 @@ type ArtistRef struct {
Name string `xml:"name,attr" json:"name"`
}
type GenreRef struct {
Name string `xml:"name,attr" json:"name"`
}
type Album struct {
// common
ID *specid.ID `xml:"id,attr,omitempty" json:"id"`
@@ -134,7 +138,7 @@ type Album struct {
TrackCount int `xml:"songCount,attr" json:"songCount"`
Duration int `xml:"duration,attr" json:"duration"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
Genres []string `xml:"genres,omitempty" json:"genres,omitempty"`
Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"`
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
// star / rating