diff --git a/README.md b/README.md index ab0a38d..97d2e34 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ url = "https://www.youtube.com" # full yt url throttle = 1 # throttle yt request range = "1:5:1" # [START][:STOP][:STEP] 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 ``` diff --git a/internal/config/config.go b/internal/config/config.go index bd348e9..05b285d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,13 +8,14 @@ import ( ) type Provider struct { - Url string - Throttle int - Range string - After_date string - Cmd string - Cookies string - Opml_file string + Url string + Throttle int + Range string + After_date string + Cmd string + Cookies bool + Cookies_file string + Opml_file string } type Config struct { diff --git a/internal/dl/dl.go b/internal/dl/dl.go index fac5802..28bef57 100644 --- a/internal/dl/dl.go +++ b/internal/dl/dl.go @@ -36,17 +36,7 @@ func Get(d Download, p config.Provider) { panic(err) } - var simulate string - if d.DryRun == true { - simulate = "--simulate" - log.Printf("/!\\ DRY RUN ENABLED /!\\") - } else { - simulate = "--no-simulate" - } - - cmd := exec.Command(p.Cmd, - fullUrl.String(), - simulate, + args := []string{ "--no-progress", "--sleep-interval", 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, "--restrict-filenames", "--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() if err != nil {