ytdl-web/ytdl/stream.go

27 lines
391 B
Go

package ytdl
import (
"io"
"os/exec"
"github.com/spf13/viper"
)
func Stream(wr io.Writer, url string, format Format) error {
cmd := exec.Command(
viper.GetString("ytdlp_path"),
"-o", "-",
"-f", format.FormatID,
"--merge-output-format", "mkv",
"--cookies-from-browser", "firefox",
url,
)
cmd.Stdout = wr
if err := cmd.Run(); err != nil {
return err
}
return nil
}