feat: control use of cookies_file
All checks were successful
build / build (push) Successful in 1m49s

This commit is contained in:
Viktor Varland 2025-03-29 08:55:38 +01:00
parent 70fa49e16a
commit 7535cd1a1b
Signed by: varl
GPG key ID: 7459F0B410115EE8
3 changed files with 29 additions and 21 deletions

View file

@ -15,7 +15,8 @@ url = "https://www.youtube.com" # full yt url
throttle = 1 # throttle yt request throttle = 1 # throttle yt request
range = "1:5:1" # [START][:STOP][:STEP] range = "1:5:1" # [START][:STOP][:STEP]
after_date = "20250326" # not in use after_date = "20250326" # not in use
cookies = "./cookies.txt" # pass user cookies to yt cookies = false # control use of cookies file
cookies_file = "./cookies.txt" # pass user cookies to yt
opml_file = "./opml.xml" # the opml file to use opml_file = "./opml.xml" # the opml file to use
``` ```

View file

@ -13,7 +13,8 @@ type Provider struct {
Range string Range string
After_date string After_date string
Cmd string Cmd string
Cookies string Cookies bool
Cookies_file string
Opml_file string Opml_file string
} }

View file

@ -36,17 +36,7 @@ func Get(d Download, p config.Provider) {
panic(err) panic(err)
} }
var simulate string args := []string{
if d.DryRun == true {
simulate = "--simulate"
log.Printf("/!\\ DRY RUN ENABLED /!\\")
} else {
simulate = "--no-simulate"
}
cmd := exec.Command(p.Cmd,
fullUrl.String(),
simulate,
"--no-progress", "--no-progress",
"--sleep-interval", strconv.Itoa(p.Throttle), "--sleep-interval", strconv.Itoa(p.Throttle),
"--sleep-subtitles", strconv.Itoa(p.Throttle), "--sleep-subtitles", strconv.Itoa(p.Throttle),
@ -62,8 +52,24 @@ func Get(d Download, p config.Provider) {
"--playlist-items", p.Range, "--playlist-items", p.Range,
"--restrict-filenames", "--restrict-filenames",
"--embed-metadata", "--embed-metadata",
"--cookies", p.Cookies, }
)
if d.DryRun == true {
args = append(args, "--simulate")
log.Printf("/!\\ DRY RUN ENABLED /!\\")
} else {
args = append(args, "--no-simulate")
}
if p.Cookies == true {
args = append(args, "--cookies")
args = append(args, p.Cookies_file)
} else {
args = append(args, "--no-cookies")
}
args = append(args, fullUrl.String())
cmd := exec.Command(p.Cmd, args...)
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if err != nil { if err != nil {