Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Lehmann
426e3ce84f Make sure directories are created. 2025-09-17 22:49:55 +02:00
Michael Lehmann
a7d770bf28 Update devenv. 2025-09-17 22:49:16 +02:00
3 changed files with 22 additions and 13 deletions

View File

@@ -3,10 +3,10 @@
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1734605856,
"lastModified": 1758136890,
"owner": "cachix",
"repo": "devenv",
"rev": "f81cf7dc4cbfa46de11618af94e5983c5e600d8c",
"rev": "9ed7eb30c3d0d16d3127da7e18562e243a4d6d7d",
"type": "github"
},
"original": {
@@ -40,10 +40,10 @@
]
},
"locked": {
"lastModified": 1750779888,
"lastModified": 1758108966,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
"rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b",
"type": "github"
},
"original": {
@@ -74,10 +74,10 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1733477122,
"lastModified": 1755783167,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857",
"rev": "4a880fb247d24fbca57269af672e8f78935b0328",
"type": "github"
},
"original": {

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!")

15
main.go
View File

@@ -3,8 +3,10 @@ package main
import (
"flag"
"fmt"
"kattudden/newsboat-yt/config"
"kattudden/newsboat-yt/database"
"kattudden/newsboat-yt/download"
"kattudden/newsboat-yt/utils"
)
func main() {
@@ -14,6 +16,19 @@ func main() {
flag.Parse()
conf, _ := config.New()
err := utils.EnsureDirectory(conf.DownloadPath)
if err != nil {
fmt.Println("failed to create download directory!")
return
}
err = utils.EnsureDirectory(conf.DatabaseDirectory)
if err != nil {
fmt.Println("failed to create database directory!")
return
}
if *newUrl != "" {
fmt.Println("Adding new URL.")
database.InsertUrl(*newUrl)