From 3d48456ab28515db8cf83906c193a707d4f449df Mon Sep 17 00:00:00 2001 From: himawari <54976075+guohuiyuan@users.noreply.github.com> Date: Sat, 4 May 2024 23:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ 添加新参数 * 🐛 修改参数问题 --- bilibili/api.go | 18 +++++++++++++----- bilibili/api_test.go | 8 -------- bilibili/types.go | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bilibili/api.go b/bilibili/api.go index 8d17959..54a5d1e 100644 --- a/bilibili/api.go +++ b/bilibili/api.go @@ -195,7 +195,7 @@ func GetVideoInfo(id string) (card Card, err error) { } // GetVideoSummary 用av或bv查看AI视频总结 -func GetVideoSummary(id string) (videoSummary VideoSummary, err error) { +func GetVideoSummary(cookiecfg *CookieConfig, id string) (videoSummary VideoSummary, err error) { var ( data []byte card Card @@ -213,10 +213,18 @@ func GetVideoSummary(id string) (videoSummary VideoSummary, err error) { if err != nil { return } - data, err = web.GetData(SignURL(fmt.Sprintf(VideoSummaryURL, card.BvID, card.CID))) - if err != nil { - return - } + data, err = web.RequestDataWithHeaders(web.NewDefaultClient(), SignURL(fmt.Sprintf(VideoSummaryURL, card.BvID, card.CID, card.Owner.Mid)), "GET", func(req *http.Request) error { + if cookiecfg != nil { + cookie := "" + cookie, err = cookiecfg.Load() + if err != nil { + return err + } + req.Header.Add("cookie", cookie) + } + req.Header.Set("User-Agent", web.RandUA()) + return nil + }, nil) err = json.Unmarshal(data, &videoSummary) return } diff --git a/bilibili/api_test.go b/bilibili/api_test.go index 262fcb1..d42a4d8 100644 --- a/bilibili/api_test.go +++ b/bilibili/api_test.go @@ -12,14 +12,6 @@ func TestGetAllGuard(t *testing.T) { t.Logf("%+v\n", guardUser) } -func TestGetVideoSummary(t *testing.T) { - videoSummary, err := GetVideoSummary("BV1ju4y1s7kn") - if err != nil { - t.Fatal(err) - } - t.Logf("%+v\n", videoSummary) -} - func TestGetDynamicDetail(t *testing.T) { cfg := NewCookieConfig("config.json") detail, err := GetDynamicDetail(cfg, "851252197280710664") diff --git a/bilibili/types.go b/bilibili/types.go index 9b04982..5acc560 100644 --- a/bilibili/types.go +++ b/bilibili/types.go @@ -46,7 +46,7 @@ const ( // AllGuardURL 查询所有舰长,提督,总督 AllGuardURL = "https://api.vtbs.moe/v1/guard/all" // VideoSummaryURL AI视频总结 - VideoSummaryURL = "https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=%v&cid=%v" + 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" )