add save playlist feature
This commit is contained in:
parent
26f230e039
commit
cdf12411a2
4 changed files with 30 additions and 7 deletions
20
mpd.go
20
mpd.go
|
@ -367,10 +367,28 @@ func deletePlaylist(c echo.Context) error {
|
|||
|
||||
err = conn.PlaylistRemove(name)
|
||||
if err != nil {
|
||||
c.Logger().Error(fmt.Sprintf("Couldn't delete playlist %s", name))
|
||||
c.Logger().Error(err)
|
||||
return c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusNoContent, "")
|
||||
}
|
||||
|
||||
func savePlaylist(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")
|
||||
|
||||
err = conn.PlaylistSave(name)
|
||||
if err != nil {
|
||||
c.Logger().Error(err)
|
||||
return c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusCreated, "")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue