package ytdl import ( "fmt" "os/exec" "path/filepath" ) var yturl = "https://youtu.be/%s" func NewYTdl(vid string) ([]byte, error) { uri, err := exec.Command( "./bin/yt-dlp_linux", fmt.Sprintf(yturl, vid), "--cookies", "./cookies.txt", "--no-call-home", "--no-cache-dir", "--ignore-errors", "--newline", "--restrict-filenames", "-f", "140", "--get-url", ).Output() if err != nil { return nil, err } return uri, nil } func DownloadAmbiance(uri string, name string) error { err := exec.Command( "./bin/yt-dlp_linux", uri, "-x", "--audio-format", "mp3", "--postprocessor-args", "-ar 48000 -ac 2", "--cookies", "./cookies.txt", "--no-call-home", "--no-cache-dir", "--restrict-filenames", "-f", "140", "-o", filepath.Join("./ambiance/", name+".mp3"), ).Run() if err != nil { return nil } return nil }