Skip to content

Commit

Permalink
✨ 添加新参数 (#50)
Browse files Browse the repository at this point in the history
* ✨ 添加新参数

* 🐛 修改参数问题
  • Loading branch information
guohuiyuan authored May 4, 2024
1 parent 2cf39e6 commit 3d48456
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 13 additions & 5 deletions bilibili/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
8 changes: 0 additions & 8 deletions bilibili/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion bilibili/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit 3d48456

Please sign in to comment.