add TestDownloadSections

This commit is contained in:
ar2rworld
2023-08-23 16:48:24 -04:00
parent 3184158e02
commit e29655f2bd

View File

@ -285,6 +285,35 @@ func TestSubtitles(t *testing.T) {
}
}
func TestDownloadSections(t *testing.T) {
defer leakChecks(t)()
ydlResult, ydlResultErr := goutubedl.New(
context.Background(),
"https://www.youtube.com/watch?v=OyuL5biOQ94",
goutubedl.Options{
DownloadSections: "*0:0-0:5",
})
if ydlResult.Options.DownloadSections != "*0:0-0:5" {
t.Errorf("failed to setup --download-sections")
}
if ydlResultErr != nil {
t.Errorf("failed to download: %s", ydlResultErr)
}
dr, err := ydlResult.Download(context.Background(), ydlResult.Info.Formats[0].FormatID)
if err != nil {
t.Fatal(err)
}
downloadBuf := &bytes.Buffer{}
_, err = io.Copy(downloadBuf, dr)
if err != nil {
t.Fatal(err)
}
dr.Close()
}
func TestErrorNotAPlaylist(t *testing.T) {
defer leakChecks(t)()