)
//消息队列
+type Danmu_Main_mq_item struct {
+ Class string
+ Data interface{}
+}
var Danmu_Main_mq = mq.New()
//from player-loader-2.0.11.min.js
弹幕重连
直播流开播自动下载
直播流下载重连
-gtk弹幕窗自定义人/事件消息停留
+gtk弹幕窗自定义人/事件消息停留/房间切换/弹幕格式化发送
营收统计
...
```
私の隣の一万は幻ですか?
====
```
+```
+//gtk的弹幕格式化发送
+2020/11/20 15:39:57 弹幕格式已设置为 [{D}]
+INFO: 2020/11/20 15:40:05 [弹幕发送] [发送 [就是这样] 至 394988]
+[就是这样]
+INFO: 2020/11/20 15:40:15 [弹幕发送] [发送 [你知道么] 至 394988]
+[你知道么]
+2020/11/20 15:42:38 弹幕长度大于20,不做格式处理
+INFO: 2020/11/20 15:42:38 [弹幕发送] [发送 11111111111111111111 至 394988]
+11111111111111111111
+```
ctrl+c退出,会同时追加记录到文件danmu.log中(文件记录完整信息,不会减少附加功能作用的弹幕)
- 流保存以及弹幕ass
```
"errors"
"strconv"
"time"
+ "strings"
"log"
"fmt"
var w2_textView1 *gtk.TextView
var w2_Entry0 *gtk.Entry
var w2_Entry0_editting bool
-
+
application, err := gtk.ApplicationNew(appId, glib.APPLICATION_FLAGS_NONE)
if err != nil {log.Println(err);return}
w2_textView1 = tmp
}else{log.Println("cant find #t1 in .glade");return}
}
+ {//发送弹幕
+ var danmu_send_form string
+ {//发送弹幕格式
+ obj, err := builder2.GetObject("send_danmu_form")
+ if err != nil {log.Println(err);return}
+ if tmp,ok := obj.(*gtk.Entry); ok {
+ tmp.Connect("focus-out-event", func() {
+ if t,e := tmp.GetText();e == nil && t != ``{
+ danmu_send_form = t
+ log.Println("弹幕格式已设置为",danmu_send_form)
+ }
+ })
+ }else{log.Println("cant find #send_danmu in .glade");return}
+ }
+ obj, err := builder2.GetObject("send_danmu")
+ if err != nil {log.Println(err);return}
+ if tmp,ok := obj.(*gtk.Entry); ok {
+ tmp.Connect("key-release-event", func(entry *gtk.Entry, event *gdk.Event) {
+ eventKey := gdk.EventKeyNewFromEvent(event)
+ if eventKey.KeyVal() == gdk.KEY_Return {
+ if t,e := entry.GetText();e == nil && t != ``{
+ danmu_want_send := t
+ if danmu_send_form != `` {danmu_want_send = strings.ReplaceAll(danmu_send_form, "{D}", t)}
+ if len([]rune(danmu_want_send)) > 20 {
+ log.Println(`弹幕长度大于20,不做格式处理`)
+ danmu_want_send = t
+ }
+ Msg_senddanmu(danmu_want_send)
+ entry.SetText(``)
+ }
+ }
+ })
+ }else{log.Println("cant find #send_danmu in .glade");return}
+ }
{//房间id
obj, err := builder2.GetObject("want_room_id")
if err != nil {log.Println(err);return}
y(`输入错误`,load_face("0room"))
} else {
c.Roomid = i
- c.Danmu_Main_mq.Push(`change_room`)
+ c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{
+ Class:`change_room`,
+ })
}
} else {
y(`房间号输入为空`,load_face("0room"))
}
}
- PostStr := `color=16777215&fontsize=25&mode=1&msg=` + msg + `&rnd=` + strconv.Itoa(int(p.Sys().GetMTime())) + `&roomid=` + strconv.Itoa(roomid) + `&bubble=0&csrf_token=` + csrf + `&csrf=` + csrf
-
+ PostStr := `color=16777215&fontsize=25&mode=1&msg=` + msg + `&rnd=` + strconv.Itoa(int(p.Sys().GetSTime())) + `&roomid=` + strconv.Itoa(roomid) + `&bubble=0&csrf_token=` + csrf + `&csrf=` + csrf
l.I("发送", msg, "至", roomid)
r := p.Req()
err := r.Reqf(p.Rval{
PostStr:PostStr,
Timeout:5,
Header:map[string]string{
+ `Host`: `api.live.bilibili.com`,
+ `User-Agent`: `Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0`,
+ `Accept`: `application/json, text/javascript, */*; q=0.01`,
+ `Accept-Language`: `zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2`,
+ `Accept-Encoding`: `gzip, deflate, br`,
+ `Content-Type`: `application/x-www-form-urlencoded; charset=UTF-8`,
+ `Origin`: `https://live.bilibili.com`,
+ `Connection`: `keep-alive`,
+ `Pragma`: `no-cache`,
+ `Cache-Control`: `no-cache`,
`Referer`:"https://live.bilibili.com/" + strconv.Itoa(roomid),
`Cookie`:Cookie,
},
)
for {
data,sig = c.Danmu_Main_mq.Pull(sig)
- if data.(string) != `change_room` {continue}
+ if d,ok := data.(c.Danmu_Main_mq_item);!ok || d.Class != `change_room` {continue}
+ c.Rev = 0 //营收
change_room_chan <- true
}
}()
<object class="GtkGrid" id="grid0">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_left">2</property>
+ <property name="margin_right">2</property>
<property name="margin_top">2</property>
<property name="margin_bottom">2</property>
<property name="orientation">vertical</property>
- <property name="row_spacing">3</property>
+ <property name="row_spacing">4</property>
<property name="column_spacing">2</property>
<child>
<object class="GtkExpander">
<property name="margin_left">2</property>
<property name="margin_right">2</property>
<property name="hexpand">True</property>
- <property name="vexpand">False</property>
+ <property name="vexpand">True</property>
<property name="expanded">True</property>
<child>
<object class="GtkGrid">
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">3</property>
- <property name="column_spacing">2</property>
+ <property name="column_spacing">3</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_left">2</property>
+ <property name="margin_right">2</property>
<property name="margin_top">2</property>
</object>
<packing>
<property name="top_attach">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkExpander">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="expanded">True</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkEntry" id="send_danmu">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_top">3</property>
+ <property name="hexpand">True</property>
+ <property name="max_length">20</property>
+ <property name="activates_default">True</property>
+ <property name="truncate_multiline">True</property>
+ <property name="placeholder_text" translatable="yes">回车发送</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">内容</property>
+ <property name="width_chars">6</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</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">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="send_danmu_form">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_bottom">3</property>
+ <property name="placeholder_text" translatable="yes">{D}由内容替换后发送,本项可为空</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">发送弹幕</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
</object>
</child>
</object>