]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
大负载下表现
authorqydysky <qydysky@foxmail.com>
Sat, 19 Dec 2020 10:26:24 +0000 (18:26 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 19 Dec 2020 10:26:24 +0000 (18:26 +0800)
CV/Var.go
F/api.go
README.md
Reply/F.go
Reply/Reply.go
Reply/gtk.go
Reply/tts.go
bili_danmu.go
demo/config/config_tts.json
demo/ui/2.glade

index 0fedb05f8eaeb3eba40994e50597c91f5011bfba..71b2422af2c8a6469009bba83cc90e25628fd1ea 100644 (file)
--- 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//是否在直播
 )
index f1baea1f37f005a1b3a62cb3a305cafc27aff3e8..a4be0f73e02736a722e4666a1cb119e37c748731 100644 (file)
--- 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,
                        },
index 1a7c252309d226b3e5a09d2b9cc84f0144bb1a8f..06e9ae957bf3c78b3c51516a9d55be64574b17e6 100644 (file)
--- 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`才可用**
index 723e9da5ccd5d26a729ffba22f86707ad4f206f8..b2674eb8ea9850d2f71b8099efb0a5834a0c2b45 100644 (file)
@@ -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
 }
index b0557058c1838df03c9bfcbaef5484196090f2b3..44e00002f376cc22e1d933f7c0086e9cdb1295c2 100644 (file)
@@ -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)
        }
index 2641fe77e61a0fe613ac984186df708e7b3277ef..be88f60aeebd46a8a47ef337d9483b49b8399eb5 100644 (file)
@@ -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}
index f9cf8fcf6f4003842e6be5747adcd05197b73d7e..a7c305250278079d04007ed08560c191a06c8dd8 100644 (file)
@@ -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")
index 3220e6ea92511c669e32135d29079b190715260e..dbded07bf95d558f206a68e2a753e988cf96cc3f 100644 (file)
@@ -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
index 67e82351828472ff6a78f375aec88f21a5b865b8..52b02c8e8eb8277c898a3e9b4884802fbf8aa415 100644 (file)
@@ -2,6 +2,5 @@
        "0buyguide":"感谢{D}",
        "0gift":"感谢{D}",
     "0superchat":"感谢{D}",
-    "0multi":"观众:{D}",
-    "0follow":"感谢{D}"
+    "0multi":"观众:{D}"
 }
\ No newline at end of file
index fdbcac23a663ae71be796d662701efad941dae20..50df04ee5e4f87b72185d03bcecbaa03348f9ab9 100644 (file)
                             <property name="top_attach">4</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">排行榜</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">5</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkTextView" id="t4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="editable">False</property>
+                            <property name="justification">right</property>
+                            <property name="cursor_visible">False</property>
+                            <property name="accepts_tab">False</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">5</property>
+                          </packing>
+                        </child>
                         <style>
                           <class name="this_time_body"/>
                         </style>