Files
newsboat-yt/download/download.go
2025-09-17 22:49:55 +02:00

29 lines
550 B
Go

package download
import (
"errors"
"fmt"
"kattudden/newsboat-yt/config"
"os/exec"
)
func YoutubeVideo(url string) error {
conf, _ := config.New()
downloadBinary := "yt-dlp"
output := fmt.Sprintf("%s/%%(title)s.%%(ext)s", conf.DownloadPath)
args := []string{"-S", "filesize~100M", "-f", "bv+(ba[format_note*=original]/ba)", "-o", output, url}
cmd := exec.Command(downloadBinary, args...)
fmt.Println(cmd.String())
err := cmd.Run()
if err != nil {
fmt.Println(err)
return errors.New("failed to download video!")
}
return nil
}