From 077fc84d0a7b075330a0c0d038d1b7f7bd998b42 Mon Sep 17 00:00:00 2001 From: himawari <1156544355@qq.com> Date: Sat, 4 May 2024 23:35:06 +0800 Subject: [PATCH 1/2] =?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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bilibili/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" ) From ba2c531ac2ecf38586d6105fd223d55922fa23fe Mon Sep 17 00:00:00 2001 From: himawari <1156544355@qq.com> Date: Sat, 4 May 2024 23:48:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E6=94=B9=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bilibili/api.go | 18 +++++++++++++----- bilibili/api_test.go | 8 -------- 2 files changed, 13 insertions(+), 13 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")