diff --git a/downloader/downloader.go b/downloader/downloader.go index b374dc30f..6abd1a447 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -587,6 +587,13 @@ func (downloader *Downloader) Download(data *extractors.Data) error { stream = data.Streams[s.ID] break } + for _, part := range s.Parts { + if part.Ext == "m4a" { + isFound = true + stream = data.Streams[s.ID] + break + } + } } if !isFound { return errors.Errorf("No audio stream found") @@ -658,6 +665,10 @@ func (downloader *Downloader) Download(data *extractors.Data) error { break } + if downloader.option.AudioOnly && (part.Ext != "m4a") { + continue + } + partFileName := fmt.Sprintf("%s[%d]", title, index) partFilePath, err := utils.FilePath(partFileName, part.Ext, downloader.option.FileNameLength, downloader.option.OutputPath, false) if err != nil { @@ -687,7 +698,7 @@ func (downloader *Downloader) Download(data *extractors.Data) error { } downloader.bar.Finish() - if data.Type != extractors.DataTypeVideo { + if data.Type != extractors.DataTypeVideo || downloader.option.AudioOnly { return nil }