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

Feature danmakusuki #388

Merged
merged 14 commits into from
Aug 27, 2022
Merged
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 查成分 [xxx]

- [x] 设置b站cookie SESSDATA=82da790d,1663822823,06ecf\*31
- [x] 查弹幕 [xxx] 2 (最后一个参数是页码)

- [x] 设置b站cookie SESSDATA=82da790d,1663822823,06ecf\*31 (最好把cookie设全)

- [x] 更新vup

Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// package main 主函数
fumiama marked this conversation as resolved.
Show resolved Hide resolved
package main

import (
Expand Down
30 changes: 23 additions & 7 deletions plugin/bilibili/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,32 @@ var (

// searchUser 查找b站用户
func searchUser(keyword string) (r []searchResult, err error) {
data, err := web.GetData(fmt.Sprintf(searchUserURL, keyword))
client := &http.Client{}
req, err := http.NewRequest("GET", fmt.Sprintf(searchUserURL, keyword), nil)
if err != nil {
return
}
err = reflushBilibiliCookie()
if err != nil {
return
}
req.Header.Add("cookie", cfg.BilibiliCookie)
res, err := client.Do(req)
if err != nil {
return
}
j := gjson.ParseBytes(data)
if j.Get("data.numResults").Int() == 0 {
err = errors.New("查无此人")
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
s := fmt.Sprintf("status code: %d", res.StatusCode)
err = errors.New(s)
return
}
err = json.Unmarshal(binary.StringToBytes(j.Get("data.result").Raw), &r)
var sd searchData
err = json.NewDecoder(res.Body).Decode(&sd)
if err != nil {
return
}
r = sd.Data.Result
return
}

Expand Down Expand Up @@ -66,8 +79,11 @@ func getMedalwall(uid string) (result []medal, err error) {
if err != nil {
return
}
c := vdb.getBilibiliCookie()
req.Header.Add("cookie", c.Value)
err = reflushBilibiliCookie()
if err != nil {
return
}
req.Header.Add("cookie", cfg.BilibiliCookie)
res, err := client.Do(req)
if err != nil {
return
Expand Down
Loading