Skip to content

Commit

Permalink
fix:bilibili API
Browse files Browse the repository at this point in the history
请求API时需要带UA
  • Loading branch information
vatebur committed Jan 6, 2025
1 parent 4f48a17 commit 67fd8d3
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bilibili/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func GetDynamicDetail(cookiecfg *CookieConfig, dynamicIDStr string) (card Dynami

// GetMemberCard 获取b站个人详情
func GetMemberCard(uid any) (result MemberCard, err error) {
data, err := web.GetData(fmt.Sprintf(MemberCardURL, uid))
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(MemberCardURL, uid), "GET", "", web.RandUA(), nil)
if err != nil {
return
}
Expand Down
117 changes: 102 additions & 15 deletions bilibili/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,108 @@ type Vote struct {

// MemberCard 个人信息卡片
type MemberCard struct {
Mid string `json:"mid"`
Name string `json:"name"`
Sex string `json:"sex"`
Face string `json:"face"`
Coins float64 `json:"coins"`
Regtime int64 `json:"regtime"`
Birthday string `json:"birthday"`
Sign string `json:"sign"`
Attentions []int64 `json:"attentions"`
Fans int `json:"fans"`
Friend int `json:"friend"`
Attention int `json:"attention"`
LevelInfo struct {
CurrentLevel int `json:"current_level"`
} `json:"level_info"`
Code int `json:"code"`
Message string `json:"message"`
Ttl int `json:"ttl"`

Check failure on line 203 in bilibili/types.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field Ttl should be TTL (revive)
Data struct {
Card struct {
Mid string `json:"mid"`
Name string `json:"name"`
Approve bool `json:"approve"`
Sex string `json:"sex"`
Rank string `json:"rank"`
Face string `json:"face"`
FaceNft int `json:"face_nft"`
FaceNftType int `json:"face_nft_type"`
DisplayRank string `json:"DisplayRank"`
Regtime int64 `json:"regtime"`
Spacesta int `json:"spacesta"`
Birthday string `json:"birthday"`
Place string `json:"place"`
Description string `json:"description"`
Article int `json:"article"`
Attentions []int64 `json:"attentions"`
Fans int `json:"fans"`
Friend int `json:"friend"`
Attention int `json:"attention"`
Sign string `json:"sign"`
LevelInfo struct {
CurrentLevel int `json:"current_level"`
CurrentMin int `json:"current_min"`
CurrentExp int `json:"current_exp"`
NextExp int `json:"next_exp"`
} `json:"level_info"`
Pendant struct {
Pid int `json:"pid"`
Name string `json:"name"`
Image string `json:"image"`
Expire int `json:"expire"`
ImageEnhance string `json:"image_enhance"`
ImageEnhanceFrame string `json:"image_enhance_frame"`
NPid int `json:"n_pid"`
} `json:"pendant"`
Nameplate struct {
Nid int `json:"nid"`
Name string `json:"name"`
Image string `json:"image"`
ImageSmall string `json:"image_small"`
Level string `json:"level"`
Condition string `json:"condition"`
} `json:"nameplate"`
Official struct {
Role int `json:"role"`
Title string `json:"title"`
Desc string `json:"desc"`
Type int `json:"type"`
} `json:"Official"`
OfficialVerify struct {
Type int `json:"type"`
Desc string `json:"desc"`
} `json:"official_verify"`
Vip struct {
Type int `json:"type"`
Status int `json:"status"`
DueDate int64 `json:"due_date"`
VipPayType int `json:"vip_pay_type"`
ThemeType int `json:"theme_type"`
Label struct {
Path string `json:"path"`
Text string `json:"text"`
LabelTheme string `json:"label_theme"`
TextColor string `json:"text_color"`
BgStyle int `json:"bg_style"`
BgColor string `json:"bg_color"`
BorderColor string `json:"border_color"`
UseImgLabel bool `json:"use_img_label"`
ImgLabelUriHans string `json:"img_label_uri_hans"`

Check failure on line 274 in bilibili/types.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field ImgLabelUriHans should be ImgLabelURIHans (revive)
ImgLabelUriHant string `json:"img_label_uri_hant"`

Check failure on line 275 in bilibili/types.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field ImgLabelUriHant should be ImgLabelURIHant (revive)
ImgLabelUriHansStatic string `json:"img_label_uri_hans_static"`

Check failure on line 276 in bilibili/types.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field ImgLabelUriHansStatic should be ImgLabelURIHansStatic (revive)
ImgLabelUriHantStatic string `json:"img_label_uri_hant_static"`

Check failure on line 277 in bilibili/types.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field ImgLabelUriHantStatic should be ImgLabelURIHantStatic (revive)
} `json:"label"`
AvatarSubscript int `json:"avatar_subscript"`
NicknameColor string `json:"nickname_color"`
Role int `json:"role"`
AvatarSubscriptUrl string `json:"avatar_subscript_url"`

Check failure on line 282 in bilibili/types.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: struct field AvatarSubscriptUrl should be AvatarSubscriptURL (revive)
TvVipStatus int `json:"tv_vip_status"`
TvVipPayType int `json:"tv_vip_pay_type"`
TvDueDate int `json:"tv_due_date"`
AvatarIcon struct {
IconType int `json:"icon_type"`
IconResource struct {
} `json:"icon_resource"`
} `json:"avatar_icon"`
VipType int `json:"vipType"`
VipStatus int `json:"vipStatus"`
} `json:"vip"`
IsSeniorMember int `json:"is_senior_member"`
NameRender interface{} `json:"name_render"`
} `json:"card"`
Following bool `json:"following"`
ArchiveCount int `json:"archive_count"`
ArticleCount int `json:"article_count"`
Follower int `json:"follower"`
LikeNum int `json:"like_num"`
} `json:"data"`
}

// RoomCard 直播间卡片
Expand Down

0 comments on commit 67fd8d3

Please sign in to comment.