Add yt-dlp path config value
This commit is contained in:
parent
6fed527515
commit
0b990c082b
|
@ -50,16 +50,19 @@ func init() {
|
|||
rootCmd.PersistentFlags().IntP("port", "p", 8080, "port to listen on (default is 8080)")
|
||||
rootCmd.PersistentFlags().StringP("listen", "l", "127.0.0.1", "address to listen on (default is 127.0.0.1)")
|
||||
rootCmd.PersistentFlags().StringP("base-path", "b", "", "the base path, used when behind reverse proxy (default is \"\")")
|
||||
rootCmd.PersistentFlags().StringP("ytdlp-path", "y", "yt-dlp", "the path to the yt-dlp binary, used when it is not in $PATH (default is yt-dlp)")
|
||||
|
||||
// trunk-ignore-begin(golangci-lint/errcheck): Ignoring errors
|
||||
viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port"))
|
||||
viper.BindPFlag("listen", rootCmd.PersistentFlags().Lookup("listen"))
|
||||
viper.BindPFlag("base_path", rootCmd.PersistentFlags().Lookup("base-path"))
|
||||
viper.BindPFlag("ytdlp_path", rootCmd.PersistentFlags().Lookup("ytdlp-path"))
|
||||
// trunk-ignore-end(golangci-lint/errcheck)
|
||||
|
||||
viper.SetDefault("port", 8080)
|
||||
viper.SetDefault("listen", "127.0.0.1")
|
||||
viper.SetDefault("base_path", "")
|
||||
viper.SetDefault("ytdlp_path", "yt-dlp")
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
port: 8080
|
||||
listen: 0.0.0.0
|
||||
base_path: ""
|
||||
ytdlp_path: yt-dlp
|
||||
|
|
|
@ -4,11 +4,13 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"os/exec"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func GetMetadata(url string) (Metadata, error) {
|
||||
cmd := exec.Command(
|
||||
"yt-dlp",
|
||||
viper.GetString("ytdlp_path"),
|
||||
"-J",
|
||||
"--cookies-from-browser", "firefox",
|
||||
url,
|
||||
|
|
|
@ -3,11 +3,13 @@ package ytdl
|
|||
import (
|
||||
"io"
|
||||
"os/exec"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func Stream(wr io.Writer, url string, format Format) error {
|
||||
cmd := exec.Command(
|
||||
"yt-dlp",
|
||||
viper.GetString("ytdlp_path"),
|
||||
"-o", "-",
|
||||
"-f", format.FormatID,
|
||||
"--merge-output-format", "mkv",
|
||||
|
|
Loading…
Reference in New Issue