Skip to content

Instantly share code, notes, and snippets.

@owulveryck
Created June 2, 2017 09:52
Show Gist options
  • Save owulveryck/70d97e1e73d664c1c927c253a862ac17 to your computer and use it in GitHub Desktop.
Save owulveryck/70d97e1e73d664c1c927c253a862ac17 to your computer and use it in GitHub Desktop.
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