diff --git a/client.go b/client.go index 1a574f2e..641f95a4 100644 --- a/client.go +++ b/client.go @@ -351,7 +351,7 @@ func (c *Client) getChunkSize() int64 { return c.ChunkSize } - return Size1Mb + return Size10Mb } func (c *Client) getMaxRoutines(limit int) int { diff --git a/video_test.go b/video_test.go index 668832ed..fecf8d7a 100644 --- a/video_test.go +++ b/video_test.go @@ -1,7 +1,6 @@ package youtube import ( - "fmt" "io" "testing" "time" @@ -9,56 +8,48 @@ import ( "github.com/stretchr/testify/require" ) -func TestChunk(t *testing.T) { - fmt.Println(getChunks(100, 10)) -} - -func TestSimpleTest(t *testing.T) { - client := Client{Debug: true, ChunkSize: Size10Mb} +func ExampleClient_GetStream() { + client := Client{Debug: true} - video, err := client.GetVideo("https://www.youtube.com/watch?v=BaW_jenozKc") + video, err := client.GetVideo("https://www.youtube.com/watch?v=9_MbW9FK1fA") if err != nil { panic(err) } // Typically youtube only provides separate streams for video and audio. // If you want audio and video combined, take a look a the downloader package. - format := video.Formats.FindByQuality("hd1080") - - start := time.Now() + format := video.Formats.FindByQuality("medium") reader, _, err := client.GetStream(video, format) - require.NoError(t, err, "get stream") - - fmt.Println("Duration Milliseconds: ", time.Since(start).Milliseconds()) - - // do something with the reader - b, err := io.ReadAll(reader) if err != nil { panic(err) } - fmt.Println("Downloaded ", len(b)) + // do something with the reader + + reader.Close() } -func ExampleClient_GetStream() { - client := Client{Debug: true} +func TestSimpleTest(t *testing.T) { + client := Client{Debug: true, ChunkSize: Size10Mb} - video, err := client.GetVideo("https://www.youtube.com/watch?v=9_MbW9FK1fA") - if err != nil { - panic(err) - } + video, err := client.GetVideo("https://www.youtube.com/watch?v=BaW_jenozKc") + require.NoError(t, err, "get body") // Typically youtube only provides separate streams for video and audio. // If you want audio and video combined, take a look a the downloader package. - format := video.Formats.FindByQuality("medium") + format := video.Formats.FindByQuality("hd1080") + + start := time.Now() reader, _, err := client.GetStream(video, format) - if err != nil { - panic(err) - } + require.NoError(t, err, "get stream") + + t.Log("Duration Milliseconds: ", time.Since(start).Milliseconds()) // do something with the reader + b, err := io.ReadAll(reader) + require.NoError(t, err, "read body") - reader.Close() + t.Log("Downloaded ", len(b)) } func TestDownload_Regular(t *testing.T) {