add replace playlist feature
This commit is contained in:
parent
44dd0ddd9c
commit
aeaef11341
4 changed files with 37 additions and 10 deletions
24
mpd.go
24
mpd.go
|
@ -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, "")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue