From ae007cbb01688cbefc7701f93c487b0d41379e7d Mon Sep 17 00:00:00 2001 From: Juan Cuzmar Date: Wed, 13 Mar 2024 23:46:25 -0300 Subject: [PATCH] new feature new feature added. now you can use cookies from browser option --- goutubedl.go | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/goutubedl.go b/goutubedl.go index 2324365..2a82b32 100644 --- a/goutubedl.go +++ b/goutubedl.go @@ -217,19 +217,20 @@ var TypeFromString = map[string]Type{ // Options for New() type Options struct { - Type Type - PlaylistStart uint // --playlist-start - PlaylistEnd uint // --playlist-end - Downloader string // --downloader - DownloadThumbnail bool - DownloadSubtitles bool - DownloadSections string // --download-sections - ProxyUrl string // --proxy URL http://host:port or socks5://host:port - DebugLog Printer - StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr - HTTPClient *http.Client // Client for download thumbnail and subtitles (nil use http.DefaultClient) - MergeOutputFormat string // --merge-output-format - SortingFormat string // --format-sort + Type Type + PlaylistStart uint // --playlist-start + PlaylistEnd uint // --playlist-end + Downloader string // --downloader + DownloadThumbnail bool + DownloadSubtitles bool + DownloadSections string // --download-sections + ProxyUrl string // --proxy URL http://host:port or socks5://host:port + CookiesFromBrowser string // --cookies-from-browser BROWSER[:FOLDER] + DebugLog Printer + StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr + HTTPClient *http.Client // Client for download thumbnail and subtitles (nil use http.DefaultClient) + MergeOutputFormat string // --merge-output-format + SortingFormat string // --format-sort // Set to true if you don't want to use the result.Info structure after the goutubedl.New() call, // so the given URL will be downloaded in a single pass in the DownloadResult.Download() call. @@ -319,6 +320,11 @@ func infoFromURL( if options.Downloader != "" { cmd.Args = append(cmd.Args, "--downloader", options.Downloader) } + + if options.CookiesFromBrowser != "" { + cmd.Args = append(cmd.Args, "--cookies-from-browser", options.CookiesFromBrowser) + } + switch options.Type { case TypePlaylist, TypeChannel: cmd.Args = append(cmd.Args, "--yes-playlist") @@ -610,6 +616,10 @@ func (result Result) DownloadWithOptions( cmd.Args = append(cmd.Args, "--download-sections", result.Options.DownloadSections) } + if result.Options.CookiesFromBrowser != "" { + cmd.Args = append(cmd.Args, "--cookies-from-browser", result.Options.CookiesFromBrowser) + } + if result.Options.MergeOutputFormat != "" { cmd.Args = append(cmd.Args, "--merge-output-format", result.Options.MergeOutputFormat,