Fix: default quality

pull/31/head
zijiren233 1 year ago
parent 16acae8bf5
commit 1fc33cf9ba

@ -150,8 +150,8 @@ type VendorInfo struct {
}
type BilibiliVendorInfo struct {
Bvid string `json:"bvid"`
Cid uint `json:"cid"`
Epid uint `json:"epid"`
Quality uint `json:"quality"`
Bvid string `json:"bvid,omitempty"`
Cid uint `json:"cid,omitempty"`
Epid uint `json:"epid,omitempty"`
Quality uint `json:"quality,omitempty"`
}

@ -91,6 +91,12 @@ type GetVideoURLConf struct {
Quality uint
}
func (c *GetVideoURLConf) fix() {
if c.Quality == 0 {
c.Quality = Q1080PP
}
}
type GetVideoURLConfig func(*GetVideoURLConf)
func WithQuality(q uint) GetVideoURLConfig {
@ -107,6 +113,8 @@ func (c *Client) GetVideoURL(aid uint, bvid string, cid uint, conf ...GetVideoUR
for _, v := range conf {
v(config)
}
config.fix()
var url string
if aid != 0 {
url = fmt.Sprintf("https://api.bilibili.com/x/player/wbi/playurl?aid=%d&cid=%d&qn=%d&platform=html5&high_quality=1", aid, cid, config.Quality)
@ -234,6 +242,7 @@ func (c *Client) GetPGCURL(ep_id, cid uint, conf ...GetVideoURLConfig) (*VideoUR
for _, v := range conf {
v(config)
}
config.fix()
var url string
if ep_id != 0 {

Loading…
Cancel
Save