youtube-dl to yt-dlp

master v0.10
Bel LaPointe 2021-08-23 17:30:07 -04:00
parent d256ad7916
commit 53d7c826ef
2 changed files with 23 additions and 7 deletions

View File

@ -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:]...)

View File

@ -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
}