-
Notifications
You must be signed in to change notification settings - Fork 436
/
transcript_test.go
52 lines (38 loc) · 1.26 KB
/
transcript_test.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
package youtube
import (
"strconv"
"testing"
"github.com/stretchr/testify/require"
)
func TestTranscript(t *testing.T) {
video := &Video{ID: "9_MbW9FK1fA"}
transcript, err := testClient.GetTranscript(video, "en")
require.NoError(t, err, "get transcript")
require.Greater(t, len(transcript), 0, "no transcript segments found")
for i, segment := range transcript {
index := strconv.Itoa(i)
require.NotEmpty(t, segment.Text, "text "+index)
require.NotEmpty(t, segment.Duration, "duration "+index)
require.NotEmpty(t, segment.OffsetText, "offset "+index)
if i != 0 {
require.NotEmpty(t, segment.StartMs, "startMs "+index)
}
}
t.Log(transcript.String())
}
func TestTranscriptOtherLanguage(t *testing.T) {
video := &Video{ID: "AXwDvYh2-uk"}
transcript, err := testClient.GetTranscript(video, "id")
require.NoError(t, err, "get transcript")
require.Greater(t, len(transcript), 0, "no transcript segments found")
for i, segment := range transcript {
index := strconv.Itoa(i)
require.NotEmpty(t, segment.Text, "text "+index)
require.NotEmpty(t, segment.Duration, "duration "+index)
require.NotEmpty(t, segment.OffsetText, "offset "+index)
if i != 0 {
require.NotEmpty(t, segment.StartMs, "startMs "+index)
}
}
t.Log(transcript.String())
}