add updateDb method

This commit is contained in:
XenGi 2023-12-29 16:55:06 +01:00
parent 99d50084f2
commit dd41374467
Signed by: xengi
SSH key fingerprint: SHA256:FGp51kRvGOcWnTHiOI39ImwVO4A3fpvR30nPX3LpV7g
2 changed files with 17 additions and 0 deletions

16
mpd.go
View file

@ -11,6 +11,22 @@ import (
// MPD API calls
func updateDb(c echo.Context) error {
// Connect to MPD server
conn, err := mpd.Dial("tcp", "localhost:6600")
if err != nil {
log.Fatalln(err)
}
defer conn.Close()
jobId, err := conn.Update("")
if err != nil {
log.Fatalln(err)
}
return c.String(http.StatusOK, strconv.Itoa(jobId))
}
func previousTrack(c echo.Context) error {
// Connect to MPD server
conn, err := mpd.Dial("tcp", "localhost:6600")

View file

@ -78,6 +78,7 @@ func main() {
})
g := e.Group("/api")
g.GET("/update_db", updateDb)
g.GET("/previous_track", previousTrack)
g.GET("/next_track", nextTrack)
g.GET("/stop", stopPlayback)