new feature
new feature added. now you can use cookies from browser option
This commit is contained in:
36
goutubedl.go
36
goutubedl.go
@ -217,19 +217,20 @@ var TypeFromString = map[string]Type{
|
|||||||
|
|
||||||
// Options for New()
|
// Options for New()
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Type Type
|
Type Type
|
||||||
PlaylistStart uint // --playlist-start
|
PlaylistStart uint // --playlist-start
|
||||||
PlaylistEnd uint // --playlist-end
|
PlaylistEnd uint // --playlist-end
|
||||||
Downloader string // --downloader
|
Downloader string // --downloader
|
||||||
DownloadThumbnail bool
|
DownloadThumbnail bool
|
||||||
DownloadSubtitles bool
|
DownloadSubtitles bool
|
||||||
DownloadSections string // --download-sections
|
DownloadSections string // --download-sections
|
||||||
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
|
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
|
||||||
DebugLog Printer
|
CookiesFromBrowser string // --cookies-from-browser BROWSER[:FOLDER]
|
||||||
StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr
|
DebugLog Printer
|
||||||
HTTPClient *http.Client // Client for download thumbnail and subtitles (nil use http.DefaultClient)
|
StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr
|
||||||
MergeOutputFormat string // --merge-output-format
|
HTTPClient *http.Client // Client for download thumbnail and subtitles (nil use http.DefaultClient)
|
||||||
SortingFormat string // --format-sort
|
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,
|
// 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.
|
// 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 != "" {
|
if options.Downloader != "" {
|
||||||
cmd.Args = append(cmd.Args, "--downloader", 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 {
|
switch options.Type {
|
||||||
case TypePlaylist, TypeChannel:
|
case TypePlaylist, TypeChannel:
|
||||||
cmd.Args = append(cmd.Args, "--yes-playlist")
|
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)
|
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 != "" {
|
if result.Options.MergeOutputFormat != "" {
|
||||||
cmd.Args = append(cmd.Args,
|
cmd.Args = append(cmd.Args,
|
||||||
"--merge-output-format", result.Options.MergeOutputFormat,
|
"--merge-output-format", result.Options.MergeOutputFormat,
|
||||||
|
Reference in New Issue
Block a user