forked from hum/vcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
87 lines (77 loc) · 2.85 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package vcat
import (
"encoding/xml"
)
type Video struct {
Metadata *VideoMetadata `json:"metadata"`
Transcript []TranscriptTextChunk `json:"transcript"`
}
// VideoMetadata stores information related to the video, e.g. the title, or the thumbnails
type VideoMetadata struct {
VideoId string `json:"videoId"`
Title string `json:"title"`
LengthSeconds string `json:"lengthSeconds"`
Keywords []string `json:"keywords"`
ChannelId string `json:"channelId"`
ShortDescription string `json:"shortDescription"`
Thumbnail struct {
Thumbnails []struct {
Url string `json:"url"`
Width int `json:"width"`
Height int `json:"height"`
} `json:"thumbnails"`
} `json:"thumbnail"`
ViewCount string `json:"viewCount"`
Author string `json:"author"`
IsPrivate bool `json:"isPrivate"`
IsLiveContent bool `json:"isLiveContent"`
}
type TranscriptTextChunk struct {
Start string `json:"start"` // Start time of the text
End string `json:"end"` // End time of the text
Duration float64 `json:"duration"` // Approximate duration of the speech in `text`
Text string `json:"text"` // The text being said in the current time bucket
}
// AvailableLanguage holds the available translation data of transcripts provided by YouTube
type AvailableLanguage struct {
// Full name of the language translation, e.g. "English"
Name string `json:"name"`
// Code representation of the language's name, e.g. "en"
Code string `json:"code"`
}
// Captions represent the main structure
// which holds all of the necessary data to retrieve the actual captions
type captions struct {
PlayerCaptionsTracklistRenderer struct {
CaptionTracks []struct {
BaseUrl string `json:"baseUrl"`
Name struct {
SimpleText string `json:"simpleText"`
} `json:"name"`
LanguageCode string `json:"languageCode"`
Kind string `json:"asr"`
IsTranslatable bool `json:"isTranslatable"`
} `json:"captionTracks"`
TranslationLanguages []struct {
LanguageCode string
LanguageName struct {
SimpleText string `json:"simpleText"`
} `json:"languageName"`
} `json:"translationLanguages"`
} `json:"playerCaptionsTracklistRenderer"`
}
// Transcript is the underlying structure for processing the raw data of the transcript.
type transcript struct {
XMLName xml.Name `xml:"transcript" json:"-"`
Text []struct {
XMLName xml.Name `xml:"text" json:"-"`
Start string `xml:"start,attr" json:"start"` // Start time of the text
End string `json:"end"`
Duration float64 `xml:"dur,attr" json:"duration"` // Approximate duration of the speech in `text`
Text string `xml:",innerxml" json:"text"` // The text being said in the current time bucket
} `xml:"text" json:"data"`
}
type rawVideoDetail struct {
metadata *VideoMetadata
captions captions
}