From da992500f806bb87b06559d920ee12b7680955ee Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Thu, 16 Jun 2022 16:32:31 +0200 Subject: feat: Add worker Add a simple worker to manage a work queue. Right now, it is bit brittled and has no test coverage yet, but it works. Also moved from pico.css to bulma, I like the idea of classes approach of pico but for me bulma yields a better result. --- yt/manager.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'yt/manager.go') diff --git a/yt/manager.go b/yt/manager.go index 190387f..c0cf6cb 100644 --- a/yt/manager.go +++ b/yt/manager.go @@ -2,16 +2,12 @@ package yt import ( "fmt" - "io" "os/exec" ) -func RunYtDlpProcess(link string, output string) string { +func RunYtDlpProcess(link string, output string) { output_template := fmt.Sprintf("%s/%%(title)s.%%(ext)s", output) - cmd := exec.Command("yt-dlp", link, "-o", output_template) - cmdOut, _ := cmd.StdoutPipe() - cmd.Start() - cmd.Wait() - cmdOutBytes, _ := io.ReadAll(cmdOut) - return string(cmdOutBytes) + downloaded_txt := fmt.Sprintf("%s/downloaded.txt", output) + cmd := exec.Command("yt-dlp", link, "-o", output_template, "--download-archive", downloaded_txt) + cmd.Run() } -- cgit v1.2.3