audio selection works

This commit is contained in:
NeilClack
2026-06-17 00:46:56 -05:00
parent 4b7d2c13d5
commit 74874f97c5
6 changed files with 598 additions and 143 deletions
+29
View File
@@ -6,6 +6,8 @@ import (
"fmt"
"io"
"net/http"
"os"
"path/filepath"
)
// Makes a GET request to the specified URL and returns the JSON response
@@ -52,3 +54,30 @@ func GetJSON[T any](url string) ([]T, error) {
return result, nil
}
// Download downloads a specified object at a given url and places it in
// the provided dest directory.
func Download(name string, path string, url string) error {
fullFilePath := filepath.Join(path, name)
if err := os.MkdirAll(path, os.ModeDir); err != nil {
return err
}
file, err := os.Create(fullFilePath)
if err != nil {
return err
}
defer file.Close()
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
_, err = io.Copy(file, resp.Body)
if err != nil {
return err
}
return nil
}