Merge pull request #195 from gamersindo1223/master
Added Download Audio Only
This commit is contained in:
25
goutubedl.go
25
goutubedl.go
@ -217,13 +217,14 @@ 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
|
||||||
UseIPV4 bool // -4 Make all connections via IPv4
|
UseIPV4 bool // -4 Make all connections via IPv4
|
||||||
Cookies string // --cookies FILE
|
Cookies string // --cookies FILE
|
||||||
@ -527,6 +528,8 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DownloadOptions struct {
|
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).
|
// 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.
|
// If filter is empty, then youtube-dl will use its default format selector.
|
||||||
Filter string
|
Filter string
|
||||||
@ -628,6 +631,14 @@ func (result Result) DownloadWithOptions(
|
|||||||
cmd.Args = append(cmd.Args, "--playlist-items", fmt.Sprint(options.PlaylistIndex))
|
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 != "" {
|
if result.Options.ProxyUrl != "" {
|
||||||
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
|
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user