tstor/pkg/ytdlp/download_test.go

28 lines
584 B
Go
Raw Permalink Normal View History

2024-05-13 16:56:20 +00:00
package ytdlp_test
import (
"context"
"fmt"
2024-06-14 22:14:44 +00:00
"io"
2024-05-13 16:56:20 +00:00
"testing"
"git.kmsign.ru/royalcat/tstor/pkg/ytdlp"
"github.com/royalcat/ctxprogress"
"github.com/stretchr/testify/require"
)
2024-06-14 22:14:44 +00:00
func TestDownload(t *testing.T) {
2024-05-13 16:56:20 +00:00
require := require.New(t)
ctx := context.Background()
c, err := ytdlp.New()
require.NoError(err)
ctx = ctxprogress.New(ctx)
ctxprogress.AddCallback(ctx, func(p ctxprogress.Progress) {
cur, total := p.Progress()
fmt.Printf("%d/%d\n", cur, total)
})
2024-06-14 22:14:44 +00:00
err = c.Download(ctx, "https://www.youtube.com/watch?v=dQw4w9WgXcQ", io.Discard)
2024-05-13 16:56:20 +00:00
require.NoError(err)
}