Skip to content

Commit bdf29b5

Browse files
authored
Merge branch 'main' into pr5
2 parents a857579 + df64721 commit bdf29b5

File tree

3 files changed

+21
-106
lines changed

3 files changed

+21
-106
lines changed

bilibili/api.go

Lines changed: 3 additions & 3 deletions
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.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(MemberCardURL, uid), "GET", "", web.RandUA(), nil)
98+
data, err := web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(MemberCardURL, uid), "GET", "", ConstUA, nil)
9999
if err != nil {
100100
return
101101
}
@@ -157,7 +157,7 @@ func GetAllGuard(mid string) (guardUser GuardUser, err error) {
157157
// GetArticleInfo 用id查专栏信息
158158
func GetArticleInfo(id string) (card Card, err error) {
159159
var data []byte
160-
data, err = web.GetData(fmt.Sprintf(ArticleInfoURL, id))
160+
data, err = web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(ArticleInfoURL, id), "GET", "", ConstUA, nil)
161161
if err != nil {
162162
return
163163
}
@@ -168,7 +168,7 @@ func GetArticleInfo(id string) (card Card, err error) {
168168
// GetLiveRoomInfo 用直播间id查直播间信息
169169
func GetLiveRoomInfo(roomID string) (card RoomCard, err error) {
170170
var data []byte
171-
data, err = web.GetData(fmt.Sprintf(LiveRoomInfoURL, roomID))
171+
data, err = web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(LiveRoomInfoURL, roomID), "GET", "", ConstUA, nil)
172172
if err != nil {
173173
return
174174
}

bilibili/types.go

Lines changed: 17 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const (
4949
VideoSummaryURL = "https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=%v&cid=%v&up_mid=%v"
5050
// NavURL 导航URL
5151
NavURL = "https://api.bilibili.com/x/web-interface/nav"
52+
// ConstUA 浏览器UA
53+
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"
5254
)
5355

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

199201
// MemberCard 个人信息卡片
200202
type MemberCard struct {
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"`
203+
Mid string `json:"mid"`
204+
Name string `json:"name"`
205+
Sex string `json:"sex"`
206+
Face string `json:"face"`
207+
Coins float64 `json:"coins"`
208+
Regtime int64 `json:"regtime"`
209+
Birthday string `json:"birthday"`
210+
Sign string `json:"sign"`
211+
Attentions []int64 `json:"attentions"`
212+
Fans int `json:"fans"`
213+
Friend int `json:"friend"`
214+
Attention int `json:"attention"`
215+
LevelInfo struct {
216+
CurrentLevel int `json:"current_level"`
217+
} `json:"level_info"`
303218
}
304219

305220
// RoomCard 直播间卡片

niu/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func ShowAuction(gid int64) ([]AuctionInfo, error) {
347347
}
348348

349349
// Auction 购买牛牛
350-
func Auction(gid, uid int64, index int) (string, error) {
350+
func Auction(gid, uid int64, index int) (string, error) {
351351
infos, err := db.getAllNiuNiuAuction(gid)
352352
if err != nil {
353353
return "", ErrNoNiuNiuINAuction

0 commit comments

Comments
 (0)