Moved to DownloadOptions
This commit is contained in:
16
goutubedl.go
16
goutubedl.go
@ -224,7 +224,7 @@ type Options struct {
|
||||
DownloadThumbnail bool
|
||||
DownloadSubtitles bool
|
||||
DownloadSections string // --download-sections
|
||||
DownloadAudioOnly bool // -x Download audio only from video
|
||||
|
||||
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
|
||||
UseIPV4 bool // -4 Make all connections via IPv4
|
||||
CookiesFromBrowser string // --cookies-from-browser BROWSER[:FOLDER]
|
||||
@ -523,6 +523,8 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
|
||||
}
|
||||
|
||||
type DownloadOptions struct {
|
||||
AudioFormats string // --audio-formats Download audio using formats (best, aac, alac, flac, m4a, mp3, opus, vorbis, wav)
|
||||
DownloadAudioOnly bool // -x Download audio only from video
|
||||
// Download format matched by filter (usually a format id or quality designator).
|
||||
// If filter is empty, then youtube-dl will use its default format selector.
|
||||
Filter string
|
||||
@ -624,6 +626,14 @@ func (result Result) DownloadWithOptions(
|
||||
cmd.Args = append(cmd.Args, "--playlist-items", fmt.Sprint(options.PlaylistIndex))
|
||||
}
|
||||
|
||||
if options.DownloadAudioOnly {
|
||||
cmd.Args = append(cmd.Args, "-x")
|
||||
}
|
||||
|
||||
if options.AudioFormats != "" {
|
||||
cmd.Args = append(cmd.Args, "--audio-format", options.AudioFormats)
|
||||
}
|
||||
|
||||
if result.Options.ProxyUrl != "" {
|
||||
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
|
||||
}
|
||||
@ -640,10 +650,6 @@ func (result Result) DownloadWithOptions(
|
||||
cmd.Args = append(cmd.Args, "--cookies-from-browser", result.Options.CookiesFromBrowser)
|
||||
}
|
||||
|
||||
if result.Options.DownloadAudioOnly {
|
||||
cmd.Args = append(cmd.Args, "-x")
|
||||
}
|
||||
cmd.Args = append(cmd.Args, "--audio-format", "mp3")
|
||||
if result.Options.MergeOutputFormat != "" {
|
||||
cmd.Args = append(cmd.Args,
|
||||
"--merge-output-format", result.Options.MergeOutputFormat,
|
||||
|
Reference in New Issue
Block a user