Skip to content

Commit

Permalink
Adding ability to provide yt-dlp exported cookies (for YouTube Premiu…
Browse files Browse the repository at this point in the history
…m, age verification, etc.)
  • Loading branch information
boggydigital committed Dec 12, 2024
1 parent f89ce09 commit 4e055cc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cli/download_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"strings"
)

const ytDlpCookiesFilename = "cookies.txt"

var defaultYtDlpOptions = map[string]string{
"-S": "vcodec:h264,res:1080,acodec:m4a",
}
Expand Down Expand Up @@ -178,18 +180,24 @@ func downloadWithYtDlp(videoId, absFilename string) error {
}
}

ytDlpDir, err := pathways.GetAbsDir(paths.YtDlp)
if err != nil {
return dyda.EndWithError(err)
}

options := make([]string, 0)

options = append(options, videoId)
options = append(options, "-o", absFilename)

for flag, value := range defaultYtDlpOptions {
options = append(options, flag, value)
absYtDlpCookiesPath := filepath.Join(ytDlpDir, ytDlpCookiesFilename)

if _, err := os.Stat(absYtDlpCookiesPath); err == nil {
options = append(options, "--cookies", absYtDlpCookiesPath)
}

ytDlpDir, err := pathways.GetAbsDir(paths.YtDlp)
if err != nil {
return dyda.EndWithError(err)
for flag, value := range defaultYtDlpOptions {
options = append(options, flag, value)
}

absYtDlpFilename := filepath.Join(ytDlpDir, yeti.GetYtDlpBinary())
Expand Down

0 comments on commit 4e055cc

Please sign in to comment.