parent
d256ad7916
commit
53d7c826ef
|
|
@ -26,7 +26,7 @@ func (c *Client) Download(video, local string) error {
|
||||||
[]string{},
|
[]string{},
|
||||||
} {
|
} {
|
||||||
args := append([]string{
|
args := append([]string{
|
||||||
"youtube-dl",
|
"/tmp/yt-dlp",
|
||||||
"-f",
|
"-f",
|
||||||
"22",
|
"22",
|
||||||
"-o",
|
"-o",
|
||||||
|
|
@ -35,6 +35,7 @@ func (c *Client) Download(video, local string) error {
|
||||||
"--write-auto-sub",
|
"--write-auto-sub",
|
||||||
"--sub-format",
|
"--sub-format",
|
||||||
"srt",
|
"srt",
|
||||||
|
"--no-check-certificate",
|
||||||
}, extras...)
|
}, extras...)
|
||||||
args = append(args, video)
|
args = append(args, video)
|
||||||
cmd := exec.Command(args[0], args[1:]...)
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package youtubedl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -52,16 +53,30 @@ func installPyPip3FFMPEG() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func installYtdl() error {
|
func installYtdl() error {
|
||||||
cmd := exec.Command("youtube-dl", "--version")
|
cmd := exec.Command("/tmp/yt-dlp", "--version")
|
||||||
if err := cmd.Run(); err == nil {
|
if err := cmd.Run(); err == nil {
|
||||||
return err
|
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 {
|
if err := cmd.Run(); err != nil {
|
||||||
cmd = exec.Command("pip3", "install", "youtube-dl")
|
o, _ := cmd.CombinedOutput()
|
||||||
if err := cmd.Run(); err != nil {
|
return fmt.Errorf("failed wget yt-dlp: %v: %s", err, o)
|
||||||
return err
|
}
|
||||||
}
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue