-
Notifications
You must be signed in to change notification settings - Fork 3
/
video_cate_vod_list.go
69 lines (61 loc) · 2.03 KB
/
video_cate_vod_list.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
package douyuapi
import (
"github.com/birjemin/douyuapi/utils"
)
const videoCateVodListURI = "/api/thirdPart/video/cateVodList"
// VideoCateVodList ...
type VideoCateVodList struct {
BaseClient
Token string
}
// VideoCateVodListResponse ...
type VideoCateVodListResponse struct {
ErrorResponse
Data []struct {
HashID string `json:"hash_id"`
Cid1 int `json:"cid1"`
Cid2 int `json:"cid2"`
UpID string `json:"up_id"`
Nickname string `json:"nickname"`
IsVertical int `json:"is_vertical"`
VideoTitle string `json:"video_title"`
VideoCover string `json:"video_cover"`
VideoVerticalCover string `json:"video_vertical_cover"`
VideoDuration int `json:"video_duration"`
ViewNum int `json:"view_num"`
UTime int `json:"utime"`
OwnerAvatar string `json:"owner_avatar"`
VideoCollectNum int `json:"video_collect_num"`
VideoUpNum int `json:"video_up_num"`
BarrageNum int `json:"barrage_num"`
VideoURL string `json:"video_url"`
H5VideoURL string `json:"h5_video_url"`
ShareURL string `json:"share_url"`
} `json:"data"`
}
// Handle ...
func (p *VideoCateVodList) Handle(postJSON, timestamp string) (*VideoCateVodListResponse, error) {
return p.do(DouYuDomain+videoCateVodListURI, postJSON, timestamp)
}
// do
func (p *VideoCateVodList) do(url, postJSON, timestamp string) (*VideoCateVodListResponse, error) {
var params = map[string]string{
"aid": p.AID,
"time": timestamp,
"token": p.Token,
}
params["auth"] = GetSign(p.Secret, videoCateVodListURI, params)
url += "?" + utils.HTTPQueryBuild(params)
if err := p.Client.HTTPPostJSON(url, postJSON); err != nil {
return nil, err
}
var ret, errResp = new(VideoCateVodListResponse), new(ErrorResponse)
if err := p.Client.GetResponseJSON(ret, errResp); err != nil {
return nil, err
}
if errResp.Code != 0 {
ret.Code = errResp.Code
ret.Msg = errResp.Msg
}
return ret, nil
}