Skip to content

Commit 290ddf3

Browse files
authored
fix:bilibili API (#63)
请求API时需要带UA
1 parent 4f48a17 commit 290ddf3

File tree

2 files changed

+103
-16
lines changed

2 files changed

+103
-16
lines changed

bilibili/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func GetDynamicDetail(cookiecfg *CookieConfig, dynamicIDStr string) (card Dynami
9595

9696
// GetMemberCard 获取b站个人详情
9797
func GetMemberCard(uid any) (result MemberCard, err error) {
98-
data, err := web.GetData(fmt.Sprintf(MemberCardURL, uid))
98+
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(MemberCardURL, uid), "GET", "", web.RandUA(), nil)
9999
if err != nil {
100100
return
101101
}

bilibili/types.go

Lines changed: 102 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,108 @@ type Vote struct {
198198

199199
// MemberCard 个人信息卡片
200200
type MemberCard struct {
201-
Mid string `json:"mid"`
202-
Name string `json:"name"`
203-
Sex string `json:"sex"`
204-
Face string `json:"face"`
205-
Coins float64 `json:"coins"`
206-
Regtime int64 `json:"regtime"`
207-
Birthday string `json:"birthday"`
208-
Sign string `json:"sign"`
209-
Attentions []int64 `json:"attentions"`
210-
Fans int `json:"fans"`
211-
Friend int `json:"friend"`
212-
Attention int `json:"attention"`
213-
LevelInfo struct {
214-
CurrentLevel int `json:"current_level"`
215-
} `json:"level_info"`
201+
Code int `json:"code"`
202+
Message string `json:"message"`
203+
TTL int `json:"ttl"`
204+
Data struct {
205+
Card struct {
206+
Mid string `json:"mid"`
207+
Name string `json:"name"`
208+
Approve bool `json:"approve"`
209+
Sex string `json:"sex"`
210+
Rank string `json:"rank"`
211+
Face string `json:"face"`
212+
FaceNft int `json:"face_nft"`
213+
FaceNftType int `json:"face_nft_type"`
214+
DisplayRank string `json:"DisplayRank"`
215+
Regtime int64 `json:"regtime"`
216+
Spacesta int `json:"spacesta"`
217+
Birthday string `json:"birthday"`
218+
Place string `json:"place"`
219+
Description string `json:"description"`
220+
Article int `json:"article"`
221+
Attentions []int64 `json:"attentions"`
222+
Fans int `json:"fans"`
223+
Friend int `json:"friend"`
224+
Attention int `json:"attention"`
225+
Sign string `json:"sign"`
226+
LevelInfo struct {
227+
CurrentLevel int `json:"current_level"`
228+
CurrentMin int `json:"current_min"`
229+
CurrentExp int `json:"current_exp"`
230+
NextExp int `json:"next_exp"`
231+
} `json:"level_info"`
232+
Pendant struct {
233+
Pid int `json:"pid"`
234+
Name string `json:"name"`
235+
Image string `json:"image"`
236+
Expire int `json:"expire"`
237+
ImageEnhance string `json:"image_enhance"`
238+
ImageEnhanceFrame string `json:"image_enhance_frame"`
239+
NPid int `json:"n_pid"`
240+
} `json:"pendant"`
241+
Nameplate struct {
242+
Nid int `json:"nid"`
243+
Name string `json:"name"`
244+
Image string `json:"image"`
245+
ImageSmall string `json:"image_small"`
246+
Level string `json:"level"`
247+
Condition string `json:"condition"`
248+
} `json:"nameplate"`
249+
Official struct {
250+
Role int `json:"role"`
251+
Title string `json:"title"`
252+
Desc string `json:"desc"`
253+
Type int `json:"type"`
254+
} `json:"Official"`
255+
OfficialVerify struct {
256+
Type int `json:"type"`
257+
Desc string `json:"desc"`
258+
} `json:"official_verify"`
259+
Vip struct {
260+
Type int `json:"type"`
261+
Status int `json:"status"`
262+
DueDate int64 `json:"due_date"`
263+
VipPayType int `json:"vip_pay_type"`
264+
ThemeType int `json:"theme_type"`
265+
Label struct {
266+
Path string `json:"path"`
267+
Text string `json:"text"`
268+
LabelTheme string `json:"label_theme"`
269+
TextColor string `json:"text_color"`
270+
BgStyle int `json:"bg_style"`
271+
BgColor string `json:"bg_color"`
272+
BorderColor string `json:"border_color"`
273+
UseImgLabel bool `json:"use_img_label"`
274+
ImgLabelURIHans string `json:"img_label_uri_hans"`
275+
ImgLabelURIHant string `json:"img_label_uri_hant"`
276+
ImgLabelURIHansStatic string `json:"img_label_uri_hans_static"`
277+
ImgLabelURIHantStatic string `json:"img_label_uri_hant_static"`
278+
} `json:"label"`
279+
AvatarSubscript int `json:"avatar_subscript"`
280+
NicknameColor string `json:"nickname_color"`
281+
Role int `json:"role"`
282+
AvatarSubscriptURL string `json:"avatar_subscript_url"`
283+
TvVipStatus int `json:"tv_vip_status"`
284+
TvVipPayType int `json:"tv_vip_pay_type"`
285+
TvDueDate int `json:"tv_due_date"`
286+
AvatarIcon struct {
287+
IconType int `json:"icon_type"`
288+
IconResource struct {
289+
} `json:"icon_resource"`
290+
} `json:"avatar_icon"`
291+
VipType int `json:"vipType"`
292+
VipStatus int `json:"vipStatus"`
293+
} `json:"vip"`
294+
IsSeniorMember int `json:"is_senior_member"`
295+
NameRender interface{} `json:"name_render"`
296+
} `json:"card"`
297+
Following bool `json:"following"`
298+
ArchiveCount int `json:"archive_count"`
299+
ArticleCount int `json:"article_count"`
300+
Follower int `json:"follower"`
301+
LikeNum int `json:"like_num"`
302+
} `json:"data"`
216303
}
217304

218305
// RoomCard 直播间卡片

0 commit comments

Comments
 (0)