Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"time"
)
type videoIntelligence struct {
Response struct {
AnnotationResults []struct {
ShotAnnotations []struct {
EndTimeOffset string `json:"endTimeOffset"`
StartTimeOffset string `json:"startTimeOffset,omitempty"`
} `json:"shotAnnotations"`
LabelAnnotations []struct {
Locations []struct {
Level string `json:"level"`
Confidence float64 `json:"confidence"`
Segment struct {
EndTimeOffset string `json:"endTimeOffset"`
StartTimeOffset string `json:"startTimeOffset"`
} `json:"segment"`
} `json:"locations"`
LanguageCode string `json:"languageCode"`
Description string `json:"description"`
} `json:"labelAnnotations"`
InputURI string `json:"inputUri"`
} `json:"annotationResults"`
Type string `json:"@type"`
} `json:"response"`
Done bool `json:"done"`
Metadata struct {
AnnotationProgress []struct {
UpdateTime time.Time `json:"updateTime"`
StartTime time.Time `json:"startTime"`
ProgressPercent int `json:"progressPercent"`
InputURI string `json:"inputUri"`
} `json:"annotationProgress"`
Type string `json:"@type"`
} `json:"metadata"`
Name string `json:"name"`
}
func main() {
var out videoIntelligence
dec := json.NewDecoder(os.Stdin)
err := dec.Decode(&out)
if err != nil {
log.Fatal(err)
}
for _, a := range out.Response.AnnotationResults[0].LabelAnnotations {
for i := 0; i < len(a.Locations); i++ {
fmt.Printf("%v ", a.Description)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment