-
Notifications
You must be signed in to change notification settings - Fork 21
/
douyin_test.go
70 lines (67 loc) · 1.95 KB
/
douyin_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package douyin
import (
"testing"
"github.com/foamzou/audio-get/args"
"github.com/foamzou/audio-get/meta"
"github.com/foamzou/audio-get/test_helper"
)
func TestCore_FetchMetaAndResourceInfo(t *testing.T) {
type fields struct {
Opts *args.Options
}
tests := []struct {
name string
fields fields
wantMediaMeta *meta.MediaMeta
wantErr bool
}{
{
name: "test share url",
fields: fields{Opts: &args.Options{Url: "https://v.douyin.com/8BxvWBm/"}},
wantMediaMeta: &meta.MediaMeta{
Title: "【致我们单纯的小美好】主题曲:我多喜欢你,你会知道",
Description: "【致我们单纯的小美好】主题曲:我多喜欢你,你会知道",
Duration: 223,
CoverUrl: "jpeg",
Artist: "环球音乐宅急送",
Album: "抖音Video",
Audios: []meta.Audio{{
Url: ".mp3",
}},
Videos: []meta.Video{{
Url: "video",
}},
},
},
{
name: "test pc url",
fields: fields{Opts: &args.Options{Url: "https://www.douyin.com/video/7035903951505542437"}},
wantMediaMeta: &meta.MediaMeta{
Title: "七朵花《我只想要》是多少人的回忆#音乐推荐 #经典音乐#情感音乐#热门歌曲#抖音热歌#音乐mv#音乐 ",
Description: "七朵花《我只想要》是多少人的回忆#音乐推荐 #经典音乐#情感音乐#热门歌曲#抖音热歌#音乐mv#音乐 ",
Duration: 260,
CoverUrl: "jpeg",
Album: "抖音Video",
Audios: []meta.Audio{{
Url: ".mp3",
}},
Videos: []meta.Video{{
Url: "video",
}},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Core{
Opts: tt.fields.Opts,
}
gotMediaMeta, err := c.FetchMetaAndResourceInfo()
if (err != nil) != tt.wantErr {
t.Errorf("FetchMetaAndResourceInfo() error = %v, wantErr %v", err, tt.wantErr)
return
}
test_helper.TestMediaMeta(t, gotMediaMeta, tt.wantMediaMeta)
})
}
}