Compare commits
No commits in common. "master" and "v0.8" have entirely different histories.
|
|
@ -46,5 +46,4 @@ func init() {
|
||||||
POP3: as.Get("pop3").GetString(),
|
POP3: as.Get("pop3").GetString(),
|
||||||
Password: as.Get("password").GetString(),
|
Password: as.Get("password").GetString(),
|
||||||
}
|
}
|
||||||
Interval = as.GetDuration("interval")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package youtubedl
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
@ -16,17 +15,13 @@ func New() (*Client, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Download(video, local string) error {
|
func (c *Client) Download(video, local string) error {
|
||||||
if _, ok := os.LookupEnv("TEST"); ok {
|
|
||||||
log.Println("youtube-dl download", video, local)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
errs := []error{}
|
errs := []error{}
|
||||||
for _, extras := range [][]string{
|
for _, extras := range [][]string{
|
||||||
[]string{"--add-metadata", "--metadata-from-title", ".*[0-9]/[0-9][0-9] (?P<title>.+)"},
|
[]string{"--add-metadata", "--metadata-from-title", ".*[0-9]/[0-9][0-9] (?P<title>.+)"},
|
||||||
[]string{},
|
[]string{},
|
||||||
} {
|
} {
|
||||||
args := append([]string{
|
args := append([]string{
|
||||||
"/tmp/yt-dlp",
|
"youtube-dl",
|
||||||
"-f",
|
"-f",
|
||||||
"22",
|
"22",
|
||||||
"-o",
|
"-o",
|
||||||
|
|
@ -35,7 +30,6 @@ 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:]...)
|
||||||
|
|
@ -58,8 +52,7 @@ func (c *Client) Download(video, local string) error {
|
||||||
"/bin/sh",
|
"/bin/sh",
|
||||||
"-c",
|
"-c",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"true; python3 -m vtt_to_srt %q || python3 /usr/bin/vtt_to_srt.py %q || vtt_to_srt %q",
|
"true; python3 -m vtt_to_srt %q || python3 /usr/bin/vtt_to_srt.py %q",
|
||||||
path.Dir(local),
|
|
||||||
path.Dir(local),
|
path.Dir(local),
|
||||||
path.Dir(local),
|
path.Dir(local),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,11 @@ package youtubedl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func install() error {
|
func install() error {
|
||||||
if _, ok := os.LookupEnv("TEST"); ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err := installPyPip3FFMPEG(); err != nil {
|
if err := installPyPip3FFMPEG(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -53,30 +48,16 @@ func installPyPip3FFMPEG() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func installYtdl() error {
|
func installYtdl() error {
|
||||||
cmd := exec.Command("/tmp/yt-dlp", "--version")
|
cmd := exec.Command("youtube-dl", "--version")
|
||||||
if err := cmd.Run(); err == nil {
|
if err := cmd.Run(); err == nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
os.Remove("/tmp/yt-dlp")
|
cmd = exec.Command("sudo", "pip3", "install", "youtube-dl")
|
||||||
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 {
|
||||||
o, _ := cmd.CombinedOutput()
|
cmd = exec.Command("pip3", "install", "youtube-dl")
|
||||||
return fmt.Errorf("failed wget yt-dlp: %v: %s", err, o)
|
if err := cmd.Run(); err != nil {
|
||||||
}
|
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