ytdl-web/ytdl/stream.go

27 lines
391 B
Go
Raw Normal View History

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