clipper/backend/cmd/progress-test/main.go

55 lines
995 B
Go
Raw Normal View History

2021-10-27 19:34:59 +00:00
package main
import (
"context"
"io"
"log"
"git.netflux.io/rob/clipper/media"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/kkdai/youtube/v2"
)
const (
videoID = "N1BufwrE1I8"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatal(err)
}
// Create an Amazon S3 service s3Client
s3Client := s3.NewFromConfig(cfg)
// Create a Youtube client
var youtubeClient youtube.Client
// Create a VideoFetchService
2021-10-27 20:17:59 +00:00
fetchService := media.NewFetchMediaSetService(&youtubeClient, s3Client)
// Create a progressReader
progressReader, err := fetchService.FetchAudio(ctx, videoID)
2021-10-27 19:34:59 +00:00
if err != nil {
log.Fatalf("error calling fetch service: %v", err)
}
for {
2021-10-27 20:17:59 +00:00
progress, err := progressReader.Read()
2021-10-27 19:34:59 +00:00
if err != nil {
if err != io.EOF {
log.Printf("error reading progress: %v", err)
}
break
}
log.Printf("progress = %+v", progress)
}
log.Println("done")
}