load playlist content into result

This commit is contained in:
XenGi 2024-04-17 00:24:18 +02:00
parent bddc82399b
commit bb19b095b6
Signed by: xengi
SSH key fingerprint: SHA256:FGp51kRvGOcWnTHiOI39ImwVO4A3fpvR30nPX3LpV7g
3 changed files with 50 additions and 1 deletions

19
mpd.go
View file

@ -257,3 +257,22 @@ func listPlaylists(c echo.Context) error {
return c.JSON(http.StatusOK, playlists)
}
func listPlaylist(c echo.Context) error {
// Connect to MPD server
conn, err := mpd.Dial("tcp", "localhost:6600")
if err != nil {
c.Logger().Error(err)
}
defer conn.Close()
name := c.Param("name")
playlist, err := conn.PlaylistContents(name)
if err != nil {
c.Logger().Error(err)
return c.String(http.StatusBadRequest, err.Error())
}
return c.JSON(http.StatusOK, playlist)
}