Documentation
¶
Index ¶
- Variables
- func Av2Bv(aid int) string
- func Bv2Av(bvid string) int
- type AccountInformation
- type CaptchaResult
- type CardSpace
- type Cardbg
- type Client
- func (c *Client) Captcha() (*CaptchaResult, error)
- func (c *Client) GetAccountInformation() (*AccountInformation, error)
- func (c *Client) GetCookies() []*http.Cookie
- func (c *Client) GetCookiesString() string
- func (c *Client) GetCountryCrown() (*GetCountryCrownResult, error)
- func (c *Client) GetQRCode() (*QRCode, error)
- func (c *Client) GetRegionDailyCount() (*RegionDailyCount, error)
- func (c *Client) GetZoneLocation() (*ZoneLocation, error)
- func (c *Client) LoginWithPassword(param LoginWithPasswordParam) (*LoginWithPasswordResult, error)
- func (c *Client) LoginWithQRCode(param LoginWithQRCodeParam) (*LoginWithQRCodeResult, error)
- func (c *Client) LoginWithSMS(param LoginWithSMSParam) (*LoginWithSMSResult, error)
- func (c *Client) Now() (time.Time, error)
- func (c *Client) Resty() *resty.Client
- func (c *Client) SendFormRequest(method, url string, bodyParam map[string]any) (out *simplejson.Json, err error)
- func (c *Client) SendJsonRequest(method, url string, bodyParam map[string]any) (out *simplejson.Json, err error)
- func (c *Client) SendRequest(method, url string, contentType ContentType, urlParam map[string]string, ...) (out *simplejson.Json, err error)
- func (c *Client) SendSMS(param SendSMSParam) (*SendSMSResult, error)
- func (c *Client) SendUrlRequest(method, url string, urlParam map[string]string) (out *simplejson.Json, err error)
- func (c *Client) SetCookie(cookie *http.Cookie)
- func (c *Client) SetCookies(cookies []*http.Cookie)
- func (c *Client) SetCookiesString(cookiesString string)
- func (c *Client) SetRawCookies(rawCookies string)
- func (c *Client) UnwrapShortUrl(shortUrl string) (string, any, error)
- type ContentType
- type ContractInfo
- type CountryCrown
- type Error
- type Fan
- type FansDetail
- type FormatCtrl
- type Geetest
- type GetCountryCrownResult
- type Label
- type LevelInfo
- type LoginWithPasswordParam
- type LoginWithPasswordResult
- type LoginWithQRCodeParam
- type LoginWithQRCodeResult
- type LoginWithSMSParam
- type LoginWithSMSResult
- type Member
- type MemoryStorage
- type Nameplate
- type Official
- type OfficialVerify
- type Pendant
- type QRCode
- type RegionDailyCount
- type RelationUser
- type Resource
- type ResourceType
- type SendSMSParam
- type SendSMSResult
- type Size
- type Storage
- type Upper
- type UserSailing
- type Vip
- type VipLabel
- type WBI
- func (wbi *WBI) GenerateMixinKey(orig string) string
- func (wbi *WBI) GetKeys() (imgKey string, subKey string, err error)
- func (wbi *WBI) GetMixinKey() (string, error)
- func (wbi *WBI) SetKeys(imgKey, subKey string)
- func (wbi *WBI) SignMap(payload map[string]string, ts time.Time) (newPayload map[string]string, err error)
- func (wbi *WBI) SignQuery(query url.Values, ts time.Time) (newQuery url.Values, err error)
- func (wbi *WBI) WithCookies(cookies []*http.Cookie) *WBI
- func (wbi *WBI) WithMixinKeyEncTab(mixinKeyEncTab []int) *WBI
- func (wbi *WBI) WithRawCookies(rawCookies string) *WBI
- func (wbi *WBI) WithStorage(storage Storage) *WBI
- func (wbi *WBI) WithUpdateInterval(updateInterval time.Duration) *WBI
- type ZoneInfo
- type ZoneLocation
Constants ¶
This section is empty.
Variables ¶
var ( ResourceTypeVideo ResourceType = 2 // 视频稿件 ResourceTypeAudio = 12 // 音频 ResourceTypeVideoList = 21 // 视频合集 )
Functions ¶
Types ¶
type AccountInformation ¶
type AccountInformation struct { Mid int `json:"mid"` // 我的mid Uname string `json:"uname"` // 我的昵称 Userid string `json:"userid"` // 我的用户名 Sign string `json:"sign"` // 我的签名 Birthday string `json:"birthday"` // 我的生日。YYYY-MM-DD Sex string `json:"sex"` // 我的性别。男 女 保密 NickFree bool `json:"nick_free"` // 是否未设置昵称。false:设置过昵称。true:未设置昵称 Rank string `json:"rank"` // 我的会员等级 }
type CaptchaResult ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithClient ¶
func NewWithClient(restyClient *resty.Client) *Client
NewWithClient 接收一个自定义的*resty.Client为参数
func (*Client) GetAccountInformation ¶
func (c *Client) GetAccountInformation() (*AccountInformation, error)
GetAccountInformation 获取我的信息
func (*Client) GetCookiesString ¶
GetCookiesString 获取字符串格式的cookies,方便自行存储后下次使用。配合下面的 SetCookiesString 使用。
func (*Client) GetCountryCrown ¶
func (c *Client) GetCountryCrown() (*GetCountryCrownResult, error)
GetCountryCrown 获取国际冠字码
func (*Client) GetRegionDailyCount ¶
func (c *Client) GetRegionDailyCount() (*RegionDailyCount, error)
GetRegionDailyCount 获取分区当日投稿稿件数
func (*Client) GetZoneLocation ¶
func (c *Client) GetZoneLocation() (*ZoneLocation, error)
GetZoneLocation 通过ip确定地理位置
func (*Client) LoginWithPassword ¶
func (c *Client) LoginWithPassword(param LoginWithPasswordParam) (*LoginWithPasswordResult, error)
LoginWithPassword 账号密码登录,其中validate, seccode字段需要在极验人机验证后获取
func (*Client) LoginWithQRCode ¶
func (c *Client) LoginWithQRCode(param LoginWithQRCodeParam) (*LoginWithQRCodeResult, error)
LoginWithQRCode 使用扫码登录。
该方法会阻塞直到扫码成功或者已经无法扫码。
func (*Client) LoginWithSMS ¶
func (c *Client) LoginWithSMS(param LoginWithSMSParam) (*LoginWithSMSResult, error)
LoginWithSMS 使用短信验证码登录
func (*Client) SendFormRequest ¶
func (*Client) SendJsonRequest ¶
func (*Client) SendRequest ¶
func (*Client) SendSMS ¶
func (c *Client) SendSMS(param SendSMSParam) (*SendSMSResult, error)
SendSMS 发送短信验证码
func (*Client) SendUrlRequest ¶
func (*Client) SetCookies ¶
SetCookies 设置cookies
func (*Client) SetCookiesString ¶
SetCookiesString 设置Cookies,但是是字符串格式,配合 GetCookiesString 使用。有些功能必须登录或设置Cookies后才能使用。
func (*Client) SetRawCookies ¶
SetRawCookies 如果你是从浏览器request的header中直接复制出来的cookies,调用这个函数。
type ContentType ¶
type ContentType string
const ( ContentTypeUrl ContentType = "application/x-www-form-urlencoded" ContentTypeJson ContentType = "application/json" ContentTypeForm ContentType = "multipart/form-data" )
type ContractInfo ¶
type CountryCrown ¶
type FansDetail ¶
type FansDetail struct { Uid int `json:"uid"` // 用户 mid MedalId int `json:"medal_id"` // 粉丝标签 id MedalName string `json:"medal_name"` // 粉丝标签名 Score int `json:"score"` // (?) Level int `json:"level"` // 当前标签等级 Intimacy int `json:"intimacy"` // (?) MasterStatus int `json:"master_status"` // (?) IsReceive int `json:"is_receive"` // (?) }
type FormatCtrl ¶
type GetCountryCrownResult ¶
type GetCountryCrownResult struct { Common []CountryCrown `json:"common"` // 常用国家&地区 Others []CountryCrown `json:"others"` // 其他国家&地区 }
type Label ¶
type Label struct { Path string `json:"path"` // 空。作用尚不明确 Text string `json:"text"` // 会员类型文案。大会员 年度大会员 十年大会员 百年大会员 最强绿鲤鱼 LabelTheme string `json:"label_theme"` // 会员标签。vip:大会员。annual_vip:年度大会员。ten_annual_vip:十 年大会员。hundred_annual_vip:百年大会员。fools_day_hundred_annual_vip:最强绿鲤鱼 TextColor string `json:"text_color"` // 会员标签 BgStyle int `json:"bg_style"` // 1 BgColor string `json:"bg_color"` // 会员标签背景颜色。颜色码,一般为#FB7299,曾用于愚人节改变大会员配色 BorderColor string `json:"border_color"` // 会员标签边框颜色。未使用 UseImgLabel bool `json:"use_img_label"` // true 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"` // 大会员牌子图片。繁体版 }
type LoginWithPasswordParam ¶
type LoginWithPasswordParam struct { Username string `json:"username"` // 用户登录账号。手机号或邮箱地址 Password string `json:"password"` // 参数传入原密码,下文会自动转为加密后的带盐密码 Keep int `json:"keep"` // 0 Token string `json:"token"` // 登录 API token。使用 Captcha() 方法获取 Challenge string `json:"challenge"` // 极验 challenge。使用 Captcha() 方法获取 Validate string `json:"validate"` // 极验 result。极验验证后得到 Seccode string `json:"seccode"` // 极验 result +jordan。极验验证后得到 GoUrl string `json:"go_url,omitempty" request:"query,omitempty"` // 跳转 url。默认为 https://www.bilibili.com Source string `json:"source,omitempty" request:"query,omitempty"` // 登录来源。main_web:独立登录页。main_mini:小窗登录 }
type LoginWithPasswordResult ¶
type LoginWithQRCodeParam ¶
type LoginWithQRCodeParam struct {
QrcodeKey string `json:"qrcode_key"` // 扫码登录秘钥
}
type LoginWithQRCodeResult ¶
type LoginWithQRCodeResult struct { Url string `json:"url"` // 游戏分站跨域登录 url。未登录为空 RefreshToken string `json:"refresh_token"` // 刷新refresh_token。未登录为空 Timestamp int `json:"timestamp"` // 登录时间。未登录为0。时间戳 单位为毫秒 Code int `json:"code"` // 0:扫码登录成功。86038:二维码已失效。86090:二维码已扫码未确认。86101:未扫码 Message string `json:"message"` // 扫码状态信息 }
type LoginWithSMSParam ¶
type LoginWithSMSParam struct { Cid int `json:"cid"` // 国际冠字码。可以从 GetCountryCrown() 获取 Tel int `json:"tel"` // 手机号码 Code int `json:"code"` // 短信验证码。timeout 为 5min Source string `json:"source"` // 登录来源。main_web:独立登录页。main_mini:小窗登录 CaptchaKey string `json:"captcha_key"` // 短信登录 token。从 SendSMS() 请求成功后返回 GoUrl string `json:"go_url,omitempty" request:"query,omitempty"` // 跳转url。默认为 https://www.bilibili.com Keep bool `json:"keep,omitempty" request:"query,omitempty"` // 是否记住登录。true:记住登录。false:不记住登录 }
type LoginWithSMSResult ¶
type LoginWithSMSResult struct { IsNew bool `json:"is_new"` // 是否为新注册用户。false:非新注册用户。true:新注册用户 Status int `json:"status"` // 0。未知,可能0就是成功吧 Url string `json:"url"` // 跳转 url。默认为 https://www.bilibili.com }
type Member ¶
type Member struct { Mid string `json:"mid"` // 发送者 mid Uname string `json:"uname"` // 发送者昵称 Sex string `json:"sex"` // 发送者性别。男 女 保密 Sign string `json:"sign"` // 发送者签名 Avatar string `json:"avatar"` // 发送者头像 url Rank string `json:"rank"` // (?) Displayrank string `json:"DisplayRank"` // (?) LevelInfo LevelInfo `json:"level_info"` // 发送者等级 Pendant Pendant `json:"pendant"` // 发送者头像框信息 Nameplate Nameplate `json:"nameplate"` // 发送者勋章信息 OfficialVerify OfficialVerify `json:"official_verify"` // 发送者认证信息 Vip Vip `json:"vip"` // 发送者会员信息 FansDetail *FansDetail `json:"fans_detail"` // 发送者粉丝标签 Following int `json:"following"` // 是否关注该用户。需要登录(Cookie或APP) 。否则恒为0。0:未关注。1:已关注 IsFollowed int `json:"is_followed"` // 是否被该用户关注。需要登录(Cookie或APP) 。否则恒为0。0:未关注。1:已关注 UserSailing UserSailing `json:"user_sailing"` // 发送者评论条目装扮信息 IsContractor bool `json:"is_contractor"` // 是否为合作用户? ContractDesc string `json:"contract_desc"` // 合作用户说明? }
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
func (*MemoryStorage) Get ¶
func (impl *MemoryStorage) Get(key string) (v interface{}, isSet bool)
func (*MemoryStorage) Set ¶
func (impl *MemoryStorage) Set(key string, value interface{})
type OfficialVerify ¶
type Pendant ¶
type Pendant struct { Pid int `json:"pid"` // 挂件id Name string `json:"name"` // 挂件名称 Image string `json:"image"` // 挂件图片url JumpUrl string `json:"jump_url"` // 挂件跳转url Type string `json:"type"` // 装扮类型。suit:一般装扮。vip_suit:vip 装扮 Expire int `json:"expire"` // 固定值0,作用尚不明确 ImageEnhance string `json:"image_enhance"` // 头像框图片url ImageEnhanceFrame string `json:"image_enhance_frame"` // (?) }
type QRCode ¶
type QRCode struct { Url string `json:"url"` // 二维码内容 (登录页面 url) QrcodeKey string `json:"qrcode_key"` // 扫码登录秘钥。恒为32字符 }
type RegionDailyCount ¶
type RelationUser ¶
type RelationUser struct { Mid int `json:"mid"` // 用户 mid Attribute int `json:"attribute"` // 对方对于自己的关系属性。0:未关注。1:悄悄关注(现已下线)。2:已关注。6:已互粉。128:已拉黑 Mtime int `json:"mtime"` // 对方关注目标用户时间。秒级时间戳。互关后刷新 Tag []int `json:"tag"` // 目标用户将对方分组到的 id Special int `json:"special"` // 目标用户特别关注对方标识。0:否。1:是 ContractInfo ContractInfo `json:"contract_info"` // 契约计划相关信息 Uname string `json:"uname"` // 用户昵称 Face string `json:"face"` // 用户头像url FaceNft int `json:"face_nft"` // 是否为 NFT 头像。0:非 NFT 头像。1:NFT 头像 Sign string `json:"sign"` // 用户签名 OfficialVerify OfficialVerify `json:"official_verify"` // 认证信息 Vip Vip `json:"vip"` // 会员信息 NftIcon string `json:"nft_icon"` // (?) RecReason string `json:"rec_reason"` // (?) TrackId string `json:"track_id"` // (?) }
RelationUser 关系列表对象
type Resource ¶
type Resource struct { Id int Type ResourceType }
type ResourceType ¶
type ResourceType int
type SendSMSParam ¶
type SendSMSParam struct { Cid int `json:"cid"` // 国际冠字码。使用 GetCountryCrown() 方法获取 Tel int `json:"tel"` // 手机号码 Source string `json:"source"` // 登录来源。main_web:独立登录页。main_mini:小窗登录 Token string `json:"token"` // 登录 API token。使用 Captcha() 方法获取 Challenge string `json:"challenge"` // 极验 challenge。使用 Captcha() 方法获取 Validate string `json:"validate"` // 极验 result。极验验证后得到 Seccode string `json:"seccode"` // 极验 result +jordan。极验验证后得到 }
type SendSMSResult ¶
type SendSMSResult struct {
CaptchaKey string `json:"captcha_key"` // 短信登录 token。在下方传参时需要,请备用
}
type UserSailing ¶
type Vip ¶
type Vip struct { Viptype int `json:"vipType"` // 大会员类型。0:无。1:月会员。2:年以上会员 Vipduedate int `json:"vipDueDate"` // 大会员到期时间。毫秒 时间戳 Dueremark string `json:"dueRemark"` // (?) Accessstatus int `json:"accessStatus"` // (?) Vipstatus int `json:"vipStatus"` // 大会员状态。0:无。1:有 Vipstatuswarn string `json:"vipStatusWarn"` // (?) ThemeType int `json:"theme_type"` // 会员样式 id Label VipLabel `json:"label"` // 会员铭牌样式 AvatarSubscript int `json:"avatar_subscript"` // (?) AvatarSubscriptUrl string `json:"avatar_subscript_url"` // (?) NicknameColor string `json:"nickname_color"` // 昵称颜色 }
type VipLabel ¶
type VipLabel struct { Path string `json:"path"` // (?) Text string `json:"text"` // 会员类型文案 LabelTheme string `json:"label_theme"` // 会员类型。vip:大会员。annual_vip:年度大会员。ten_annual_vip:十年大会员。hundred_annual_vip:百年大会员 TextColor string `json:"text_color"` // 文字颜色? BgStyle int `json:"bg_style"` // (?) BgColor string `json:"bg_color"` // 背景颜色? BorderColor string `json:"border_color"` // 描边颜色? }
type WBI ¶
type WBI struct {
// contains filtered or unexported fields
}
WBI 签名实现 如果希望以登录的方式获取则使用 WithCookies or WithRawCookies 设置cookie 如果希望以未登录的方式获取 WithCookies(nil) 设置cookie为 nil 即可, 这是 Default 行为
!!! 使用 WBI 的接口 绝对不可以 set header Referer 会导致失败 !!! !!! 大部分使用 WBI 的接口都需要 set header Cookie !!!
see https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/misc/sign/wbi.md
func NewDefaultWbi ¶
func NewDefaultWbi() *WBI
func (*WBI) GenerateMixinKey ¶
func (*WBI) GetMixinKey ¶
func (*WBI) WithMixinKeyEncTab ¶
func (*WBI) WithRawCookies ¶
func (*WBI) WithStorage ¶
type ZoneInfo ¶
type ZoneInfo struct { Name string //中文名称 Code string //代号即英文名 MasterTid int //主分区tid Tid int //子分区tid Overview string //概述,简介 }
ZoneInfo 结构体用来表示CSV文件中的数据, 包含名称、代码、主分区tid、子分区tid,概述和备注等信息
func GetZoneInfoByTid ¶
GetZoneInfoByTid 根据名称获取ZoneInfo对象
func (ZoneInfo) GetDescription ¶
GetDescription 获取ZoneInfo对象的描述信息,描述信息分为四个部分。当前分区,主分区,描述和备注。
type ZoneLocation ¶
type ZoneLocation struct { Addr string `json:"addr"` // 公网IP地址 Country string `json:"country"` // 国家/地区名 Province string `json:"province"` // 省/州。非必须存在项 City string `json:"city"` // 城市。非必须存在项 Isp string `json:"isp"` // 运营商名 Latitude int `json:"latitude"` // 纬度 Longitude int `json:"longitude"` // 经度 ZoneId int `json:"zone_id"` // ip数据库id CountryCode int `json:"country_code"` // 国家/地区代码 }