From fc81a8fdbdd0ff5d31c6708a384617b0f1944b54 Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Wed, 18 Jan 2023 00:53:10 +0800 Subject: [PATCH] =?utf8?q?=E6=9B=B4=E6=96=B0api?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- F/api.go | 4 +-- Json/search.go | 21 +++++++++++----- cmd/cmd.go | 67 +++++++++++++++++++++++++------------------------- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/F/api.go b/F/api.go index 6a57c22..3832110 100644 --- a/F/api.go +++ b/F/api.go @@ -2521,7 +2521,7 @@ func SearchUP(s string) (list []searchresult) { }) if err := req.Reqf(reqf.Rval{ - Url: "https://api.bilibili.com/x/web-interface/search/type?__refresh__=true&_extra=&context=&page=1&page_size=10&order=online&duration=&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&category_id=&search_type=live_user&dynamic_offset=0&preload=true&com2co=true&keyword=" + url.PathEscape(s), + Url: "https://api.bilibili.com/x/web-interface/wbi/search/type?page=1&page_size=10&order=online&platform=pc&search_type=live_user&keyword=" + url.PathEscape(s), Proxy: c.C.Proxy, Header: map[string]string{ `Cookie`: reqf.Map_2_Cookies_String(Cookie), @@ -2546,7 +2546,7 @@ func SearchUP(s string) (list []searchresult) { } } - if j.Data.Numresults == 0 { + if j.Data.NumResults == 0 { apilog.L(`I: `, `没有匹配`) return } diff --git a/Json/search.go b/Json/search.go index 132890e..6cbc01b 100644 --- a/Json/search.go +++ b/Json/search.go @@ -8,12 +8,13 @@ type Search struct { Seid string `json:"seid"` Page int `json:"page"` Pagesize int `json:"pagesize"` - Numresults int `json:"numResults"` - Numpages int `json:"numPages"` + NumResults int `json:"numResults"` + NumPages int `json:"numPages"` SuggestKeyword string `json:"suggest_keyword"` RqtType string `json:"rqt_type"` CostTime struct { ParamsCheck string `json:"params_check"` + IsRiskQuery string `json:"is_risk_query"` IllegalHandler string `json:"illegal_handler"` DeserializeResponse string `json:"deserialize_response"` AsResponseFormat string `json:"as_response_format"` @@ -24,19 +25,25 @@ type Search struct { Total string `json:"total"` MainHandler string `json:"main_handler"` } `json:"cost_time"` - ExpList interface{} `json:"exp_list"` - EggHit int `json:"egg_hit"` - Result []struct { + ExpList struct { + Num5501 bool `json:"5501"` + Num6609 bool `json:"6609"` + Num7708 bool `json:"7708"` + } `json:"exp_list"` + EggHit int `json:"egg_hit"` + Result []struct { RankOffset int `json:"rank_offset"` UID int `json:"uid"` Tags string `json:"tags"` Type string `json:"type"` LiveTime string `json:"live_time"` HitColumns []string `json:"hit_columns"` + CateName string `json:"cate_name"` LiveStatus int `json:"live_status"` Area int `json:"area"` IsLive bool `json:"is_live"` Uname string `json:"uname"` + AreaV2ID int `json:"area_v2_id"` Uface string `json:"uface"` RankIndex int `json:"rank_index"` RankScore int `json:"rank_score"` @@ -44,5 +51,7 @@ type Search struct { Attentions int `json:"attentions"` } `json:"result"` ShowColumn int `json:"show_column"` + InBlackKey int `json:"in_black_key"` + InWhiteKey int `json:"in_white_key"` } `json:"data"` -} \ No newline at end of file +} diff --git a/cmd/cmd.go b/cmd/cmd.go index d938970..ffdf567 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -28,24 +28,24 @@ func Cmd() { fmt.Println("切换房间->输入数字回车") if c.C.Roomid == 0 { if _, ok := c.C.Cookie.LoadV(`bili_jct`).(string); ok { - fmt.Println("查看直播中主播->输入' live'回车") + fmt.Println("查看直播中主播->输入' liv'回车") fmt.Println("查看历史观看主播->输入' his'回车") } else { fmt.Println("登陆->输入' login'回车") } - fmt.Println("搜索主播->输入' search关键词'回车") + fmt.Println("搜索主播->输入' sea关键词'回车") fmt.Println("其他输出隔断不影响") fmt.Print("\n") continue } if _, ok := c.C.Cookie.LoadV(`bili_jct`).(string); ok { fmt.Println("发送弹幕->输入' 字符串'回车") - fmt.Println("查看直播中主播->输入' live'回车") + fmt.Println("查看直播中主播->输入' liv'回车") } else { fmt.Println("登陆->输入' login'回车") } fmt.Println("重载弹幕->输入' reload'回车") - fmt.Println("搜索主播->输入' search关键词'回车") + fmt.Println("搜索主播->输入' sea关键词'回车") fmt.Println("房间信息->输入' room'回车") fmt.Println("开始结束录制->输入' rec'回车") fmt.Println("其他输出隔断不影响") @@ -76,27 +76,35 @@ func Cmd() { } continue } - //直播间切换 - if strings.Contains(inputs, ` live`) { - if _, ok := c.C.Cookie.LoadV(`bili_jct`).(string); !ok { - cmdlog.L(`W: `, "尚未登陆,未能获取关注主播") + //进入房间 + if strings.Contains(inputs, ` to`) { + if len(inputs) == 3 { + cmdlog.L(`W: `, "未输入进入序号") continue } + fmt.Print("\n") - if len(inputs) > 5 { - if room, ok := liveList[inputs]; ok { - c.C.Roomid = room - c.C.Danmu_Main_mq.Push_tag(`change_room`, nil) - continue - } + if room, ok := liveList[inputs]; ok { + c.C.Roomid = room + c.C.Danmu_Main_mq.Push_tag(`change_room`, nil) + continue + } else { cmdlog.L(`W: `, "输入错误", inputs) + } + continue + } + //直播间切换 + if strings.Contains(inputs, ` liv`) { + if _, ok := c.C.Cookie.LoadV(`bili_jct`).(string); !ok { + cmdlog.L(`W: `, "尚未登陆,未能获取关注主播") continue } + fmt.Print("\n") for k, v := range F.Feed_list() { - liveList[` live`+strconv.Itoa(k)] = v.Roomid + liveList[` to`+strconv.Itoa(k)] = v.Roomid fmt.Printf("%d\t%s(%d)\n\t\t\t%s\n", k, v.Uname, v.Roomid, v.Title) } - fmt.Println("回复' live(序号)'进入直播间") + fmt.Println("回复' to(序号)'进入直播间") fmt.Print("\n") continue } @@ -107,24 +115,15 @@ func Cmd() { continue } fmt.Print("\n") - if len(inputs) > 4 { - if room, ok := liveList[inputs]; ok { - c.C.Roomid = room - c.C.Danmu_Main_mq.Push_tag(`change_room`, nil) - continue - } - cmdlog.L(`W: `, "输入错误", inputs) - continue - } for k, v := range F.GetHisStream() { - liveList[` his`+strconv.Itoa(k)] = v.Roomid + liveList[` to`+strconv.Itoa(k)] = v.Roomid if v.LiveStatus == 1 { fmt.Printf("%d\t%s\t%s(%d)\n\t\t\t%s\n", k, `☁`, v.Uname, v.Roomid, v.Title) } else { fmt.Printf("%d\t%s\t%s(%d)\n\t\t\t%s\n", k, ` `, v.Uname, v.Roomid, v.Title) } } - fmt.Println("回复' his(序号)'进入直播间") + fmt.Println("回复' to(序号)'进入直播间") fmt.Print("\n") continue } @@ -140,22 +139,22 @@ func Cmd() { continue } //搜索主播 - if strings.Contains(inputs, ` search`) { - if len(inputs) == 7 { + if strings.Contains(inputs, ` sea`) { + if len(inputs) == 4 { cmdlog.L(`W: `, "未输入搜索内容") continue } fmt.Print("\n") - for k, v := range F.SearchUP(inputs[7:]) { - liveList[` live`+strconv.Itoa(k)] = v.Roomid + for k, v := range F.SearchUP(inputs[4:]) { + liveList[` to`+strconv.Itoa(k)] = v.Roomid if v.Is_live { - fmt.Printf("%d\t%s\t%s\n", k, `☁`, v.Uname) + fmt.Printf("%d\t%s\t%s(%d)\n", k, `☁`, v.Uname, v.Roomid) } else { - fmt.Printf("%d\t%s\t%s\n", k, ` `, v.Uname) + fmt.Printf("%d\t%s\t%s(%d)\n", k, ` `, v.Uname, v.Roomid) } } - fmt.Println("回复' live(序号)'进入直播间") + fmt.Println("回复' to(序号)'进入直播间") fmt.Print("\n") continue -- 2.39.2