26 lines
576 B
Go
26 lines
576 B
Go
package ytdlp_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"git.kmsign.ru/royalcat/tstor/pkg/ytdlp"
|
|
"github.com/royalcat/ctxprogress"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestYtDlp(t *testing.T) {
|
|
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)
|
|
})
|
|
err = c.Download(ctx, "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "rickroll3")
|
|
require.NoError(err)
|
|
}
|