From abb9f0fccf3a6e0ff12ba8a518306c29e2180a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E9=9F=B3=E5=B9=BB=E7=A6=BB?= Date: Fri, 11 Oct 2024 15:34:43 +0800 Subject: [PATCH] fix(bilibili): update API (#59) --- bilibili/api.go | 8 +++----- bilibili/types.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bilibili/api.go b/bilibili/api.go index 48b8a2c..3377158 100644 --- a/bilibili/api.go +++ b/bilibili/api.go @@ -13,10 +13,8 @@ import ( "github.com/tidwall/gjson" ) -var ( - // ErrAPINeedCookie ... - ErrAPINeedCookie = errors.New("api need cookie") -) +// ErrAPINeedCookie ... +var ErrAPINeedCookie = errors.New("api need cookie") // SearchUser 查找b站用户 func SearchUser(cookiecfg *CookieConfig, keyword string) (r []SearchResult, err error) { @@ -101,7 +99,7 @@ func GetMemberCard(uid any) (result MemberCard, err error) { if err != nil { return } - err = json.Unmarshal(binary.StringToBytes(gjson.ParseBytes(data).Get("card").Raw), &result) + err = json.Unmarshal(binary.StringToBytes(gjson.ParseBytes(data).Get("data.card").Raw), &result) return } diff --git a/bilibili/types.go b/bilibili/types.go index 5acc560..9f17294 100644 --- a/bilibili/types.go +++ b/bilibili/types.go @@ -16,7 +16,7 @@ const ( // DynamicDetailURL 当前动态信息,一个card DynamicDetailURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id=%v" // MemberCardURL 个人信息 - MemberCardURL = "https://account.bilibili.com/api/member/getCardByMid?mid=%v" + MemberCardURL = "https://api.bilibili.com/x/web-interface/card?mid=%v" // ArticleInfoURL 查看专栏信息 ArticleInfoURL = "https://api.bilibili.com/x/article/viewinfo?id=%v" // CVURL b站专栏前缀