Add "real" TopSongs

This commit is contained in:
Deluan
2020-10-20 22:53:52 -04:00
parent b5e20c1934
commit 049ac70b2b
7 changed files with 119 additions and 3 deletions
+16 -3
View File
@@ -298,7 +298,7 @@ func (c *BrowsingController) GetSimilarSongs(w http.ResponseWriter, r *http.Requ
if err != nil {
return nil, err
}
count := utils.ParamInt(r, "count", 20)
count := utils.ParamInt(r, "count", 50)
songs, err := c.ei.SimilarSongs(ctx, id, count)
if err != nil {
@@ -325,10 +325,23 @@ func (c *BrowsingController) GetSimilarSongs2(w http.ResponseWriter, r *http.Req
return response, nil
}
// TODO Integrate with Last.FM
func (c *BrowsingController) GetTopSongs(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
ctx := r.Context()
artist, err := requiredParamString(r, "artist", "artist parameter required")
if err != nil {
return nil, err
}
count := utils.ParamInt(r, "count", 50)
songs, err := c.ei.TopSongs(ctx, artist, count)
if err != nil {
return nil, err
}
response := newResponse()
response.TopSongs = &responses.TopSongs{}
response.TopSongs = &responses.TopSongs{
Song: childrenFromMediaFiles(ctx, songs),
}
return response, nil
}