44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
)
|
|
|
|
// BilibiliSource bilibili数据源
|
|
type BilibiliSource struct{}
|
|
|
|
// GetAVData 获取av视频的数据源
|
|
func (source *BilibiliSource) GetAVData(avNo int64) (avdata []byte, err error) {
|
|
resp, err := http.DefaultClient.Get(fmt.Sprintf("https://api.bilibili.com/x/player/pagelist?aid=%d&jsonp=jsonp", avNo))
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
avdata, err = ioutil.ReadAll(resp.Body)
|
|
return
|
|
}
|
|
|
|
// GetEPData 获取ep视频的数据源
|
|
func (source *BilibiliSource) GetEPData(epNo int64) (epdata []byte, err error) {
|
|
resp, err := http.DefaultClient.Get(fmt.Sprintf("https://www.bilibili.com/bangumi/play/ep%d", epNo))
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
epdata, err = ioutil.ReadAll(resp.Body)
|
|
return
|
|
}
|
|
|
|
// GetSSData 获取ss视频的数据源
|
|
func (source *BilibiliSource) GetSSData(ssNo int64) (ssdata []byte, err error) {
|
|
resp, err := http.DefaultClient.Get(fmt.Sprintf("https://api.bilibili.com/pgc/web/season/section?season_id=%d&season_type=1", ssNo))
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer resp.Body.Close()
|
|
ssdata, err = ioutil.ReadAll(resp.Body)
|
|
return
|
|
}
|