aboutsummaryrefslogtreecommitdiff
path: root/yt/manager.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-06-16 16:32:31 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-06-16 16:32:31 +0200
commitda992500f806bb87b06559d920ee12b7680955ee (patch)
treed535f986eba7a95e5cb6b358259bc37ca6fa7ca9 /yt/manager.go
parent64496464b3812839c1e4b440bdf69cc84f39c491 (diff)
downloadmdir-da992500f806bb87b06559d920ee12b7680955ee.tar.gz
mdir-da992500f806bb87b06559d920ee12b7680955ee.tar.bz2
mdir-da992500f806bb87b06559d920ee12b7680955ee.zip
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.
Diffstat (limited to 'yt/manager.go')
-rw-r--r--yt/manager.go12
1 files changed, 4 insertions, 8 deletions
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()
}