Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bilibili API ,Rollback types #64

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 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.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(MemberCardURL, uid), "GET", "", web.RandUA(), nil)
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(MemberCardURL, uid), "GET", "", ConstUA, nil)
if err != nil {
return
}
Expand Down Expand Up @@ -157,7 +157,7 @@ func GetAllGuard(mid string) (guardUser GuardUser, err error) {
// GetArticleInfo 用id查专栏信息
func GetArticleInfo(id string) (card Card, err error) {
var data []byte
data, err = web.GetData(fmt.Sprintf(ArticleInfoURL, id))
data, err = web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(ArticleInfoURL, id), "GET", "", ConstUA, nil)
if err != nil {
return
}
Expand All @@ -168,7 +168,7 @@ func GetArticleInfo(id string) (card Card, err error) {
// GetLiveRoomInfo 用直播间id查直播间信息
func GetLiveRoomInfo(roomID string) (card RoomCard, err error) {
var data []byte
data, err = web.GetData(fmt.Sprintf(LiveRoomInfoURL, roomID))
data, err = web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(LiveRoomInfoURL, roomID), "GET", "", ConstUA, nil)
if err != nil {
return
}
Expand Down
119 changes: 17 additions & 102 deletions bilibili/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
VideoSummaryURL = "https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=%v&cid=%v&up_mid=%v"
// NavURL 导航URL
NavURL = "https://api.bilibili.com/x/web-interface/nav"
// ConstUA 浏览器UA
ConstUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
)

// DynamicCard 总动态结构体,包括desc,card
Expand Down Expand Up @@ -198,108 +200,21 @@ type Vote struct {

// MemberCard 个人信息卡片
type MemberCard struct {
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"`
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"`
}

// RoomCard 直播间卡片
Expand Down
Loading