diff --git a/main.go b/main.go index 8bd6947..f07ceac 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "net/http/httputil" "net/url" "os" + "os/exec" "strings" ) @@ -49,7 +50,12 @@ func (pr Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) { return err } - os.WriteFile(strings.ReplaceAll(req.RequestURI, "/", "_")+".txt", body, 0666) + go func() { + mp3 := strings.ReplaceAll(req.RequestURI, "/", "_") + ".mp3" + os.WriteFile(mp3, body, 0666) + // on Mac: "sudo ln -s /usr/bin/open /usr/local/bin/play" + go exec.Command("play", mp3).Run() + }() // pass on the original body into a new body 'cause the original one has been read out already. resp.Body = io.NopCloser(bytes.NewReader(body))