48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
"strconv"
|
|
)
|
|
|
|
// epDataProvider中
|
|
|
|
// AVData av视频信息
|
|
type AVData struct {
|
|
Cid int64 `json:"cid"`
|
|
Dimension struct {
|
|
Height int64 `json:"height"`
|
|
Rotate int64 `json:"rotate"`
|
|
Width int64 `json:"width"`
|
|
} `json:"dimension"`
|
|
Duration int64 `json:"duration"`
|
|
From string `json:"from"`
|
|
Page int64 `json:"page"`
|
|
Part string `json:"part"`
|
|
Vid string `json:"vid"`
|
|
Weblink string `json:"weblink"`
|
|
}
|
|
|
|
// AVResponse av视频信息请求接口返回数据
|
|
type AVResponse struct {
|
|
Code int64 `json:"code"`
|
|
Data []AVData `json:"data"`
|
|
Message string `json:"message"`
|
|
TTL int64 `json:"ttl"`
|
|
}
|
|
|
|
// GetAVData 根据videoNo从bilibili获取av数据
|
|
func (*episodeDataProvider) GetAVData(avNo int64) (avdatas []AVData, err error) {
|
|
file, err := ioutil.ReadFile("mock/av" + strconv.FormatInt(avNo, 10) + ".json")
|
|
if err != nil {
|
|
return avdatas, err
|
|
}
|
|
var resp AVResponse
|
|
err = json.Unmarshal(file, &resp)
|
|
if err != nil {
|
|
return avdatas, err
|
|
}
|
|
return resp.Data, nil
|
|
}
|