add replace playlist feature

This commit is contained in:
XenGi 2024-04-18 11:46:09 +02:00
parent 44dd0ddd9c
commit aeaef11341
Signed by: xengi
SSH key fingerprint: SHA256:FGp51kRvGOcWnTHiOI39ImwVO4A3fpvR30nPX3LpV7g
4 changed files with 37 additions and 10 deletions

24
mpd.go
View file

@ -311,3 +311,27 @@ func listPlaylist(c echo.Context) error {
return c.JSON(http.StatusOK, playlist)
}
func replaceQueue(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("playlist_name")
err = conn.Clear()
if err != nil {
c.Logger().Error(err)
return c.String(http.StatusInternalServerError, err.Error())
}
err = conn.PlaylistLoad(name, -1, -1)
if err != nil {
c.Logger().Error(err)
return c.String(http.StatusBadRequest, err.Error())
}
return c.JSON(http.StatusOK, "")
}