diff --git a/youtubedl/client.go b/youtubedl/client.go index 584b9b7..d582339 100755 --- a/youtubedl/client.go +++ b/youtubedl/client.go @@ -26,7 +26,7 @@ func (c *Client) Download(video, local string) error { []string{}, } { args := append([]string{ - "youtube-dl", + "/tmp/yt-dlp", "-f", "22", "-o", @@ -35,6 +35,7 @@ func (c *Client) Download(video, local string) error { "--write-auto-sub", "--sub-format", "srt", + "--no-check-certificate", }, extras...) args = append(args, video) cmd := exec.Command(args[0], args[1:]...) diff --git a/youtubedl/install.go b/youtubedl/install.go index 908530b..82e8d7a 100755 --- a/youtubedl/install.go +++ b/youtubedl/install.go @@ -2,6 +2,7 @@ package youtubedl import ( "errors" + "fmt" "log" "os" "os/exec" @@ -52,16 +53,30 @@ func installPyPip3FFMPEG() error { } func installYtdl() error { - cmd := exec.Command("youtube-dl", "--version") + cmd := exec.Command("/tmp/yt-dlp", "--version") if err := cmd.Run(); err == nil { return err } - cmd = exec.Command("sudo", "pip3", "install", "youtube-dl") + os.Remove("/tmp/yt-dlp") + cmd = exec.Command( + "wget", + "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp", + "--no-check-certificate", + "-O", + "/tmp/yt-dlp", + ) if err := cmd.Run(); err != nil { - cmd = exec.Command("pip3", "install", "youtube-dl") - if err := cmd.Run(); err != nil { - return err - } + o, _ := cmd.CombinedOutput() + return fmt.Errorf("failed wget yt-dlp: %v: %s", err, o) + } + cmd = exec.Command( + "chmod", + "a+rx", + "/tmp/yt-dlp", + ) + if err := cmd.Run(); err != nil { + o, _ := cmd.CombinedOutput() + return fmt.Errorf("failed chmod yt-dlp: %v: %s", err, o) } return nil }