diff --git a/download.go b/download.go index 55a104f..b3ceb67 100644 --- a/download.go +++ b/download.go @@ -8,13 +8,11 @@ import ( "os" "os/exec" "strings" - "time" "github.com/kkdai/youtube/v2" ) const OUTPUT_DIR = "C:/Users/Administrator/ytdlpVideos" -const STUCK_TIMEOUT = time.Duration(60)*time.Second func DownloadNative(event PBEvent, status chan error) { log.Printf("%s: Downloading %s", event.Record.Id, event.Record.Link) @@ -61,12 +59,12 @@ func DownloadNative(event PBEvent, status chan error) { func Download(event PBEvent, status chan error) { cmd := exec.Command("yt-dlp", - "-v", "--mark-watched", "--color", "never", "-r", "50M", "--http-chunk-size", "20M", - "-o", "C:/Users/Administrator/ytdlpVideos/%(title)s.%(ext)s", + "-N", "4", + "-o", "C:/Users/Administrator/ytdlpVideos/%(uploader)s/%(title)s.%(ext)s", "-f", "bestvideo[ext=mp4]+bestaudio[ext=m4a]", event.Record.Link) @@ -92,11 +90,9 @@ func Download(event PBEvent, status chan error) { return } - lastMessage := time.Now() stdoutScanner := bufio.NewScanner(stdout) go func() { for stdoutScanner.Scan() { - lastMessage = time.Now() log.Printf("%s: %s", event.Record.Id, stdoutScanner.Text()) } }() @@ -104,26 +100,10 @@ func Download(event PBEvent, status chan error) { stderrScanner := bufio.NewScanner(stderr) go func() { for stderrScanner.Scan() { - lastMessage = time.Now() log.Printf("%s: %s", event.Record.Id, stderrScanner.Text()) } }() - go func() { - for { - if time.Since(lastMessage) > STUCK_TIMEOUT { - log.Printf("Command timed out, killing process") - err := cmd.Process.Kill() - if err != nil { - log.Printf("Error killing process: %v", err) - } - status <- fmt.Errorf("command timed out") - return - } - time.Sleep(time.Second) - } - }() - err = cmd.Wait() if err != nil { exitError, ok := err.(*exec.ExitError)