From a5eb954abbcdfe024dfed0d3f76540f12c2f4723 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sat, 19 Dec 2020 18:26:24 +0800 Subject: [PATCH] =?utf8?q?=E5=A4=A7=E8=B4=9F=E8=BD=BD=E4=B8=8B=E8=A1=A8?= =?utf8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CV/Var.go | 1 + F/api.go | 12 ++++++++++-- README.md | 2 +- Reply/F.go | 8 +++++++- Reply/Reply.go | 7 ++++--- Reply/gtk.go | 19 ++++++++++++++++--- Reply/tts.go | 6 +++--- bili_danmu.go | 2 ++ demo/config/config_tts.json | 3 +-- demo/ui/2.glade | 25 +++++++++++++++++++++++++ 10 files changed, 70 insertions(+), 15 deletions(-) diff --git a/CV/Var.go b/CV/Var.go index 0fedb05..71b2422 100644 --- a/CV/Var.go +++ b/CV/Var.go @@ -15,6 +15,7 @@ var ( Rev float64//营收 Renqi int//人气 GuardNum int//舰长数 + Note string//分区排行 Live_Start_Time time.Time//直播开始时间 Liveing bool//是否在直播 ) diff --git a/F/api.go b/F/api.go index f1baea1..a4be0f7 100644 --- a/F/api.go +++ b/F/api.go @@ -46,7 +46,7 @@ func (i *api) Get_info() (o *api) { Roomid := strconv.Itoa(o.Roomid) r := g.Get(p.Rval{ - Url:"https://live.bilibili.com/" + Roomid, + Url:"https://live.bilibili.com/blanc/" + Roomid, }) //uid if tmp := r.S(`"uid":`, `,`, 0, 0);tmp.Err != nil { @@ -60,6 +60,10 @@ func (i *api) Get_info() (o *api) { if e := r.S(`"title":"`, `",`, 0, 0).Err;e == nil { c.Title = r.RS[0] } + //排行 + if e := r.S(`"rank_desc":"`, `",`, 0, 0).Err;e == nil { + c.Note = r.RS[0] + } //roomid if tmp := r.S(`"room_id":`, `,`, 0, 0);tmp.Err != nil { // apilog.E("room_id", tmp.Err) @@ -90,6 +94,10 @@ func (i *api) Get_info() (o *api) { apilog.E("code", code, p.Json().GetValFrom(res, "message")) return } + //排行 + if rank_desc,ok := p.Json().GetValFrom(res, "data.rankdb_info.rank_desc").(string);ok { + c.Note = rank_desc + } if Uid := p.Json().GetValFrom(res, "data.room_info.uid");Uid == nil { apilog.E("data.room_info.uid", Uid) return @@ -143,7 +151,7 @@ func (i *api) Get_live(qn ...string) (o *api) { if len(qn) == 0 || qn[0] == "0" || qn[0] == "" {//html获取 r := g.Get(p.Rval{ - Url:"https://live.bilibili.com/" + strconv.Itoa(o.Roomid), + Url:"https://live.bilibili.com/blanc/" + strconv.Itoa(o.Roomid), Header:map[string]string{ `Cookie`:Cookie, }, diff --git a/README.md b/README.md index 1a7c252..06e9ae9 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ go build -v -tags `gtk gtk_3_24` -o demo.exe -i main.go ./demo.run -q 清晰度 -r 房间ID ``` -> 清晰度可取[数值](https://github.com/qydysky/bili_danmu/blob/028d6d8ed47df4631aca7df93871a4795bedda76/CV/Var.go#L19) +> 清晰度可取[数值](https://github.com/qydysky/bili_danmu/blob/cf52498a88e885fb66dbc94fb8652cb6fa35fb26/CV/Var.go#L37) > 弹幕及礼物会记录于danmu.log中 **部分功能需要在`demo`目录(文件夹)下放置`cookie.txt`才可用** diff --git a/Reply/F.go b/Reply/F.go index 723e9da..b2674eb 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -524,7 +524,13 @@ func Autoskipf(s string, maxNum,muteSecond int) int { } autoskip.num -= 1 i, ok := autoskip.buf.LoadAndDelete(s); - if ok && i.(int) > 1 {Msg_showdanmu(nil, strconv.Itoa(i.(int)) + " x " + s,`0multi`)}//多人重复提示 + if ok {//多人重复提示 + switch i.(int) { + case 0,1: + case 2,3:Msg_showdanmu(nil, strconv.Itoa(i.(int)) + " x " + s,`0default`) + default:Msg_showdanmu(nil, strconv.Itoa(i.(int)) + " x " + s,`0multi`) + } + } }() return 0 } diff --git a/Reply/Reply.go b/Reply/Reply.go index b055705..44e0000 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -71,7 +71,7 @@ func (replyF) interact_word(s string){ Class:`tts`, Data:Danmu_mq_t{ uid:`0follow`, - msg:fmt.Sprintln(v + `关注了直播间`), + msg:fmt.Sprint(v + `关注了直播间`), }, }) } @@ -179,8 +179,8 @@ func (replyF) user_toast_msg(s string){ c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{ Class:`tts`, Data:Danmu_mq_t{ - uid:`0guard_update`, - msg:fmt.Sprintln(sh...), + uid:`0buyguide`, + msg:fmt.Sprint(sh...), }, }) } @@ -539,6 +539,7 @@ func (replyF) panel(s string){ msglog.E("note", note) return } else { + if v,ok := note.(string);ok{c.Note = v} fmt.Println("排行", note) msglog.I("排行", note) } diff --git a/Reply/gtk.go b/Reply/gtk.go index 2641fe7..be88f60 100644 --- a/Reply/gtk.go +++ b/Reply/gtk.go @@ -98,6 +98,7 @@ func Gtk_danmu() { var w2_textView1 *gtk.TextView var w2_textView2 *gtk.TextView var w2_textView3 *gtk.TextView + var w2_textView4 *gtk.TextView var renqi_old = 1 var w2_Entry0 *gtk.Entry var w2_Entry0_editting bool @@ -175,6 +176,13 @@ func Gtk_danmu() { w2_textView3 = tmp }else{log.Println("cant find #t3 in .glade");return} } + {//排名 + obj, err := builder2.GetObject("t4") + if err != nil {log.Println(err);return} + if tmp,ok := obj.(*gtk.TextView); ok { + w2_textView4 = tmp + }else{log.Println("cant find #t4 in .glade");return} + } {//发送弹幕 var danmu_send_form string {//发送弹幕格式 @@ -234,7 +242,6 @@ func Gtk_danmu() { y(`输入错误`,load_face("0room")) } else { c.Roomid = i - renqi_old = 1//人气置1 c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{ Class:`change_room`, }) @@ -446,14 +453,15 @@ func Gtk_danmu() { return } + loc := int(grid0.Container.GetChildren().Length())/2; step := 0.1 * (max - cu) if step > 0.5 { - if step > 10 {step = 10}//限制最大滚动速度 + if step > 5 {step = 5}//限制最大滚动速度 + if loc > max_danmu {step += float64(loc - max_danmu) / 10} tmp.SetValue(step + cu) } else { in_smooth_roll = false tmp.SetValue(max) - loc := int(grid0.Container.GetChildren().Length())/2; for loc > max_danmu { if i,e := grid0.GetChildAt(0,0); e != nil{i.(*gtk.Widget).Destroy()} if i,e := grid0.GetChildAt(1,0); e != nil{i.(*gtk.Widget).Destroy()} @@ -488,6 +496,11 @@ func Gtk_danmu() { if e != nil {log.Println(e);return} b.SetText(fmt.Sprintf("%d",c.GuardNum)) } + {//分区排行 + b,e := w2_textView4.GetBuffer() + if e != nil {log.Println(e);return} + b.SetText(c.Note) + } {//时长 b,e := w2_textView1.GetBuffer() if e != nil {log.Println(e);return} diff --git a/Reply/tts.go b/Reply/tts.go index f9cf8fc..a7c3052 100644 --- a/Reply/tts.go +++ b/Reply/tts.go @@ -3,7 +3,7 @@ package reply import ( - "log" + "fmt" "net/url" "strings" p "github.com/qydysky/part" @@ -60,7 +60,7 @@ func init(){ func TTS(uid,msg string) { if tts_limit.TO() {return} - log.Println(`TTS:`, uid, msg) + fmt.Println(`TTS:`, uid, msg) req := p.Req() if v,ok := tts_setting[uid];ok{ msg = strings.ReplaceAll(v, "{D}", msg) @@ -72,7 +72,7 @@ func TTS(uid,msg string) { Retry:1, SleepTime:500, });err != nil { - log.Println(`TTS:`, err) + fmt.Println(`TTS:`, err) return } p.Exec().Run(false, "ffplay", p.Sys().Cdir()+"/tts.mp3","-autoexit","-nodisp") diff --git a/bili_danmu.go b/bili_danmu.go index 3220e6e..dbded07 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -70,6 +70,8 @@ func Demo(roomid ...int) { case `change_room`: c.Rev = 0.0 //营收 c.Renqi = 1//人气置1 + c.GuardNum = 0//舰长数 + c.Note = ``//分区排行 c.Title = `` reply.Saveflv_wait()//停止保存直播流 change_room_chan <- true diff --git a/demo/config/config_tts.json b/demo/config/config_tts.json index 67e8235..52b02c8 100644 --- a/demo/config/config_tts.json +++ b/demo/config/config_tts.json @@ -2,6 +2,5 @@ "0buyguide":"感谢{D}", "0gift":"感谢{D}", "0superchat":"感谢{D}", - "0multi":"观众:{D}", - "0follow":"感谢{D}" + "0multi":"观众:{D}" } \ No newline at end of file diff --git a/demo/ui/2.glade b/demo/ui/2.glade index fdbcac2..50df04e 100644 --- a/demo/ui/2.glade +++ b/demo/ui/2.glade @@ -177,6 +177,31 @@ 4 + + + True + False + 排行榜 + + + 0 + 5 + + + + + True + True + False + right + False + False + + + 1 + 5 + + -- 2.39.2