From 3db867b0cbff9f31380f76993482f40409a6a9b1 Mon Sep 17 00:00:00 2001 From: arthemium <60220723+arthemium@users.noreply.github.com> Date: Thu, 12 Oct 2023 18:34:00 +0300 Subject: [PATCH] Create video-clip.go --- examples/video-clip.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/video-clip.go diff --git a/examples/video-clip.go b/examples/video-clip.go new file mode 100644 index 0000000..d2fe3b3 --- /dev/null +++ b/examples/video-clip.go @@ -0,0 +1,33 @@ +/ First install the go client with "go get github.com/apivideo/api.video-go-client" +// Documentation: https://github.com/apivideo/api.video-go-client/blob/main/docs/VideosApi.md#create + +package main + +import ( + "context" + "fmt" + "os" + apivideosdk "github.com/apivideo/api.video-go-client" +) +// upload a video with a clip +func main() { + client := apivideosdk.ClientBuilder("YOUR_API_KEY").Build() + // if you rather like to use the sandbox environment: + // client := apivideosdk.SandboxClientBuilder("YOUR_SANDBOX_API_KEY").Build() + video clip := apivideosdk.VideoClip{} + videoClip.SetStartTimecode("00:00:20") + videoClip.SetEndTimecode("00:00:22") + videoCreationPayload := apivideosdk.VideoCreationPayload{} + videoCreationPayload.SetTitle("my title") + videoCreationPayload.SetClip(videoClip) + res, err := client.Videos.Create(videoCreationPayload) + videoId := res.videoId + uploadRes, err := apiVideoClient.Videos.UploadFile(videoId, videoFile) + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `Videos.Create``: %v\ +", err) + } + // response from `Create`: Video + fmt.Fprintf(os.Stdout, "Response from `Videos.Create`: %v\ +", res) +}