Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 添加新参数 #50

Merged
merged 2 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading