Merge pull request #195 from gamersindo1223/master

Added Download Audio Only
This commit is contained in:
Mattias Wadman
2024-08-18 12:19:19 +02:00
committed by GitHub

View File

@ -224,6 +224,7 @@ type Options struct {
DownloadThumbnail bool
DownloadSubtitles bool
DownloadSections string // --download-sections
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
UseIPV4 bool // -4 Make all connections via IPv4
Cookies string // --cookies FILE
@ -527,6 +528,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
@ -628,6 +631,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)
}