From 40a6ff0aeeca1e237929e90e748d387313361d69 Mon Sep 17 00:00:00 2001 From: vatebur <67186678+vatebur@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:26:22 +0800 Subject: [PATCH] fix:bilibili API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 请求API时需要带UA --- bilibili/api.go | 2 +- bilibili/types.go | 117 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 103 insertions(+), 16 deletions(-) diff --git a/bilibili/api.go b/bilibili/api.go index 3377158..b785479 100644 --- a/bilibili/api.go +++ b/bilibili/api.go @@ -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 } diff --git a/bilibili/types.go b/bilibili/types.go index 9f17294..42b1cb1 100644 --- a/bilibili/types.go +++ b/bilibili/types.go @@ -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"` + 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"` + ImgLabelURIHant string `json:"img_label_uri_hant"` + ImgLabelURIHansStatic string `json:"img_label_uri_hans_static"` + ImgLabelURIHantStatic string `json:"img_label_uri_hant_static"` + } `json:"label"` + AvatarSubscript int `json:"avatar_subscript"` + NicknameColor string `json:"nickname_color"` + Role int `json:"role"` + AvatarSubscriptURL string `json:"avatar_subscript_url"` + 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 直播间卡片