Skip to content

Commit

Permalink
Merge pull request #1384 from ocfox/bilibili-audio-only
Browse files Browse the repository at this point in the history
feat: support bilibili audio only download
  • Loading branch information
iawia002 authored Sep 27, 2024
2 parents c5135e9 + 1d5f247 commit 1608a8f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1608a8f

Please sign in to comment.