From dd41374467f5b72bbbf82d441a2634d711a5b30c Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Fri, 29 Dec 2023 16:55:06 +0100 Subject: [PATCH] add updateDb method --- mpd.go | 16 ++++++++++++++++ server.go | 1 + 2 files changed, 17 insertions(+) diff --git a/mpd.go b/mpd.go index 12bac1c..80943d9 100644 --- a/mpd.go +++ b/mpd.go @@ -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") diff --git a/server.go b/server.go index fbd02c5..8095f32 100644 --- a/server.go +++ b/server.go @@ -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)