Documentation ¶
Index ¶
- Constants
- Variables
- func LoginWithQRCode(ctx context.Context, key string) (bilibili.QRCodeStatus, *http.Cookie, error)
- func LoginWithSMS(ctx context.Context, tel, code, captchaKey string) (*http.Cookie, error)
- func Match(url string) (t string, id string, err error)
- func NewSMS(ctx context.Context, tel, token, challenge, validate string) (captchaKey string, err error)
- type CaptchaResp
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) GetDashPGCURL(epid, cid uint64, conf ...GetDashVideoURLConfig) (*mpd.MPD, *mpd.MPD, error)
- func (c *Client) GetDashVideoURL(aid uint64, bvid string, cid uint64, conf ...GetDashVideoURLConfig) (*mpd.MPD, *mpd.MPD, error)
- func (c *Client) GetLiveMasterInfo(uid uint64) (*LiveMasterInfo, error)
- func (c *Client) GetLiveStreamWithQuality(cid uint64, hls bool, qn uint64) (*GetLiveStreamWithQualityResp, error)
- func (c *Client) GetLiveStreams(cid uint64, hls bool) ([]*LiveStream, error)
- func (c *Client) GetPGCURL(epid, cid uint64, conf ...GetVideoURLConfig) (*VideoURL, error)
- func (c *Client) GetSubtitles(aid uint64, bvid string, cid uint64) ([]*Subtitle, error)
- func (c *Client) GetVideoURL(aid uint64, bvid string, cid uint64, conf ...GetVideoURLConfig) (*VideoURL, error)
- func (c *Client) NewRequest(method, url string, body io.Reader, conf ...RequestOption) (req *http.Request, err error)
- func (c *Client) ParseLivePage(roomID uint64) (*VideoPageInfo, error)
- func (c *Client) ParsePGCPage(epid, seasonID uint64) (*VideoPageInfo, error)
- func (c *Client) ParseVideoPage(aid uint64, bvid string, conf ...ParseVideoPageConfig) (*VideoPageInfo, error)
- func (c *Client) SetCookies(cookies []*http.Cookie)
- func (c *Client) UserInfo() (*UserInfo, error)
- type ClientConfig
- type GetDashVideoURLConf
- type GetDashVideoURLConfig
- type GetLiveStreamWithQualityResp
- type GetVideoURLConf
- type GetVideoURLConfig
- type LiveMasterInfo
- type LiveStream
- type Nav
- type ParseVideoPageConf
- type ParseVideoPageConfig
- type RQCode
- type RequestConfig
- type RequestOption
- type Subtitle
- type UserInfo
- type VideoInfo
- type VideoPageInfo
- type VideoURL
Constants ¶
Variables ¶
View Source
var ( ErrQRCodeExpired = errors.New("qr code expired") ErrQRCodeScanned = errors.New("qr code scanned") ErrQRCodeNotScanned = errors.New("qr code not scanned") )
View Source
var ( BVRegex = regexp.MustCompile(`^(?:https://www\.bilibili\.com/video/)?((?:bv|bV|Bv|BV)\w+)(?:[/\?].*)?$`) ARegex = regexp.MustCompile(`^(?:https://www\.bilibili\.com/video/)?(?:av|aV|Av|AV)(\d+)(?:[/\?].*)?$`) SSRegex = regexp.MustCompile(`^(?:https://www\.bilibili\.com/bangumi/play/)?(?:ss|sS|Ss|SS)(\d+)(?:[/\?].*)?$`) EPRegex = regexp.MustCompile(`^(?:https://www\.bilibili\.com/bangumi/play/)?(?:ep|eP|Ep|EP)(\d+)(?:[/\?].*)?$`) B23Regex = regexp.MustCompile(`^(https://)?b23\.tv/(\w+)$`) LIVERegex = regexp.MustCompile(`^(?:https://live\.bilibili\.com/)?(\d+)(?:\?.*)?$`) )
Functions ¶
func LoginWithQRCode ¶
func LoginWithSMS ¶
Types ¶
type CaptchaResp ¶
type CaptchaResp struct { Token string `json:"token"` Gt string `json:"gt"` Challenge string `json:"challenge"` }
func NewCaptcha ¶
func NewCaptcha(ctx context.Context) (*CaptchaResp, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetDashPGCURL ¶
func (*Client) GetDashVideoURL ¶
func (c *Client) GetDashVideoURL(aid uint64, bvid string, cid uint64, conf ...GetDashVideoURLConfig) (*mpd.MPD, *mpd.MPD, error)
https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/videostream_url.md
func (*Client) GetLiveMasterInfo ¶ added in v0.3.3
func (c *Client) GetLiveMasterInfo(uid uint64) (*LiveMasterInfo, error)
func (*Client) GetLiveStreamWithQuality ¶ added in v0.3.3
func (c *Client) GetLiveStreamWithQuality(cid uint64, hls bool, qn uint64) (*GetLiveStreamWithQualityResp, error)
https://api.live.bilibili.com/room/v1/Room/playUrl?cid=1000&quality=4&platform=web
cid: room id, not sort id
platform:
web: http-flv h5: hls
qn:
2: 流畅 3: 高清 4: 原画
func (*Client) GetLiveStreams ¶ added in v0.3.3
func (c *Client) GetLiveStreams(cid uint64, hls bool) ([]*LiveStream, error)
https://api.live.bilibili.com/room/v1/Room/playUrl?cid=1000&quality=4&platform=web
cid: room id, not sort id
platform:
web: http-flv h5: hls
func (*Client) GetPGCURL ¶
func (c *Client) GetPGCURL(epid, cid uint64, conf ...GetVideoURLConfig) (*VideoURL, error)
func (*Client) GetSubtitles ¶
https://api.bilibili.com/x/player/wbi/v2?bvid=BV1sw411Q7dr&cid=1248205613
func (*Client) GetVideoURL ¶
func (c *Client) GetVideoURL(aid uint64, bvid string, cid uint64, conf ...GetVideoURLConfig) (*VideoURL, error)
https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/videostream_url.md
func (*Client) NewRequest ¶
func (*Client) ParseLivePage ¶ added in v0.3.3
func (c *Client) ParseLivePage(roomID uint64) (*VideoPageInfo, error)
https://api.live.bilibili.com/room/v1/Room/get_info
room_id: room id, can be sort id
func (*Client) ParsePGCPage ¶
func (c *Client) ParsePGCPage(epid, seasonID uint64) (*VideoPageInfo, error)
func (*Client) ParseVideoPage ¶
func (c *Client) ParseVideoPage(aid uint64, bvid string, conf ...ParseVideoPageConfig) (*VideoPageInfo, error)
func (*Client) SetCookies ¶
type ClientConfig ¶
type ClientConfig func(*Client)
func WithContext ¶
func WithContext(ctx context.Context) ClientConfig
type GetDashVideoURLConf ¶
type GetDashVideoURLConf struct {
HDR bool
}
type GetDashVideoURLConfig ¶
type GetDashVideoURLConfig func(*GetDashVideoURLConf)
func WithHDR ¶
func WithHDR(hdr bool) GetDashVideoURLConfig
type GetLiveStreamWithQualityResp ¶ added in v0.3.3
type GetLiveStreamWithQualityResp struct { *LiveStream AcceptQuality []uint64 `json:"acceptQuality"` }
type GetVideoURLConf ¶
type GetVideoURLConf struct {
Quality uint64
}
type GetVideoURLConfig ¶
type GetVideoURLConfig func(*GetVideoURLConf)
func WithQuality ¶
func WithQuality(q uint64) GetVideoURLConfig
type LiveMasterInfo ¶ added in v0.3.3
type LiveStream ¶ added in v0.3.3
type Nav ¶
type Nav struct { string `json:"path"` Text string `json:"text"` LabelTheme string `json:"label_theme"` TextColor string `json:"text_color"` BgColor string `json:"bg_color"` BorderColor string `json:"border_color"` ImgLabelURIHans string `json:"img_label_uri_hans"` ImgLabelURIHant string `json:"img_label_uri_hant"` ImgLabelURIHansStatic string `json:"img_label_uri_hans_static"` ImgLabelURIHantStatic string `json:"img_label_uri_hant_static"` BgStyle int `json:"bg_style"` UseImgLabel bool `json:"use_img_label"` } `json:"vip_label"` WbiImg struct { ImgURL string `json:"img_url"` SubURL string `json:"sub_url"` } `json:"wbi_img"` OfficialVerify struct { Desc string `json:"desc"` Type int `json:"type"` } `json:"officialVerify"` Uname string `json:"uname"` Face string `json:"face"` ShopURL string `json:"shop_url"` VipNicknameColor string `json:"vip_nickname_color"` Pendant struct { Name string `json:"name"` Image string `json:"image"` ImageEnhance string `json:"image_enhance"` ImageEnhanceFrame string `json:"image_enhance_frame"` Pid int `json:"pid"` Expire int `json:"expire"` NPid int `json:"n_pid"` } `json:"pendant"` Official struct { Title string `json:"title"` Desc string `json:"desc"` Role int `json:"role"` Type int `json:"type"` } `json:"official"` Vip struct { AvatarSubscriptURL string `json:"avatar_subscript_url"` NicknameColor string `json:"nickname_color"` Label struct { Path string `json:"path"` Text string `json:"text"` LabelTheme string `json:"label_theme"` TextColor string `json:"text_color"` BgColor string `json:"bg_color"` BorderColor string `json:"border_color"` ImgLabelURIHans string `json:"img_label_uri_hans"` ImgLabelURIHant string `json:"img_label_uri_hant"` ImgLabelURIHansStatic string `json:"img_label_uri_hans_static"` ImgLabelURIHantStatic string `json:"img_label_uri_hant_static"` BgStyle int `json:"bg_style"` UseImgLabel bool `json:"use_img_label"` } `json:"label"` AvatarSubscript int `json:"avatar_subscript"` ThemeType int `json:"theme_type"` Type int `json:"type"` VipPayType int `json:"vip_pay_type"` DueDate int64 `json:"due_date"` Role int `json:"role"` Status int `json:"status"` TvVipStatus int `json:"tv_vip_status"` TvVipPayType int `json:"tv_vip_pay_type"` TvDueDate int `json:"tv_due_date"` } `json:"vip"` Wallet struct { Mid int `json:"mid"` BcoinBalance float64 `json:"bcoin_balance"` CouponBalance int `json:"coupon_balance"` CouponDueTime int `json:"coupon_due_time"` } `json:"wallet"` LevelInfo struct { CurrentLevel int `json:"current_level"` CurrentMin int `json:"current_min"` CurrentExp int `json:"current_exp"` } `json:"level_info"` MobileVerified int `json:"mobile_verified"` FaceNft int `json:"face_nft"` VipDueDate int64 `json:"vipDueDate"` VipStatus int `json:"vipStatus"` VipType int `json:"vipType"` VipPayType int `json:"vip_pay_type"` VipThemeType int `json:"vip_theme_type"` Moral int `json:"moral"` VipAvatarSubscript int `json:"vip_avatar_subscript"` EmailVerified int `json:"email_verified"` Mid int `json:"mid"` FaceNftType int `json:"face_nft_type"` IsSeniorMember int `json:"is_senior_member"` Scores int `json:"scores"` AllowanceCount int `json:"allowance_count"` AnswerStatus int `json:"answer_status"` HasShop bool `json:"has_shop"` IsLogin bool `json:"isLogin"` IsJury bool `json:"is_jury"` } `json:"data"` }VipLabel struct { Path
type ParseVideoPageConf ¶
type ParseVideoPageConf struct {
GetSections bool
}
type ParseVideoPageConfig ¶
type ParseVideoPageConfig func(*ParseVideoPageConf)
func WithGetSections ¶
func WithGetSections(getSections bool) ParseVideoPageConfig
type RequestConfig ¶
type RequestConfig struct {
// contains filtered or unexported fields
}
type RequestOption ¶
type RequestOption func(*RequestConfig)
func WithoutWbi ¶
func WithoutWbi() RequestOption
type VideoPageInfo ¶
Click to show internal directories.
Click to hide internal directories.