feat(subsonic): expose all album genres in a list of subsonic api
expose album genres from getArtist
This commit is contained in:
@@ -74,6 +74,7 @@ func (c *Controller) ServeGetArtist(r *http.Request) *spec.Response {
|
||||
Group("albums.id")
|
||||
}).
|
||||
Preload("Albums.Artists").
|
||||
Preload("Albums.Genres").
|
||||
Preload("ArtistStar", "user_id=?", user.ID).
|
||||
Preload("ArtistRating", "user_id=?", user.ID).
|
||||
First(artist, id.Value)
|
||||
|
||||
@@ -15,7 +15,6 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
|
||||
Name: a.TagTitle,
|
||||
Year: a.TagYear,
|
||||
TrackCount: a.ChildCount,
|
||||
Genre: strings.Join(a.GenreStrings(), ", "),
|
||||
Duration: a.Duration,
|
||||
AverageRating: formatRating(a.AverageRating),
|
||||
}
|
||||
@@ -41,6 +40,12 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
|
||||
Name: a.Name,
|
||||
})
|
||||
}
|
||||
if len(a.Genres) > 0 {
|
||||
ret.Genre = a.Genres[0].Name
|
||||
}
|
||||
for _, g := range a.Genres {
|
||||
ret.Genres = append(ret.Genres, g.Name)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,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"`
|
||||
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
|
||||
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
|
||||
// star / rating
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021,
|
||||
"song": [
|
||||
{
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"name": "album-0",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -36,6 +38,8 @@
|
||||
"name": "album-1",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -50,6 +54,8 @@
|
||||
"name": "album-2",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
}
|
||||
]
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"name": "album-0",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -36,6 +38,8 @@
|
||||
"name": "album-1",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -50,6 +54,8 @@
|
||||
"name": "album-2",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
}
|
||||
]
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"name": "album-0",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -36,6 +38,8 @@
|
||||
"name": "album-1",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -50,6 +54,8 @@
|
||||
"name": "album-2",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -34,6 +35,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -49,6 +51,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -64,6 +67,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -79,6 +83,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -94,6 +99,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -109,6 +115,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -124,6 +131,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
},
|
||||
{
|
||||
@@ -139,6 +147,7 @@
|
||||
"songCount": 0,
|
||||
"duration": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": ["Unknown Genre"],
|
||||
"year": 2021
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user