Make sure directories are created.

This commit is contained in:
Michael Lehmann
2025-09-17 22:49:55 +02:00
parent a7d770bf28
commit 426e3ce84f
2 changed files with 16 additions and 7 deletions

View File

@@ -4,18 +4,12 @@ import (
"errors"
"fmt"
"kattudden/newsboat-yt/config"
"kattudden/newsboat-yt/utils"
"os/exec"
)
func YoutubeVideo(url string) error {
conf, _ := config.New()
err := utils.EnsureDirectory(conf.DownloadPath)
if err != nil {
return errors.New("failed to create download directory!")
}
downloadBinary := "yt-dlp"
output := fmt.Sprintf("%s/%%(title)s.%%(ext)s", conf.DownloadPath)
@@ -24,7 +18,7 @@ func YoutubeVideo(url string) error {
fmt.Println(cmd.String())
err = cmd.Run()
err := cmd.Run()
if err != nil {
fmt.Println(err)
return errors.New("failed to download video!")