demo/main
demo/face/*
demo/demo.run
+demo/ui/*.glade~
package cv
-
+
+import (
+ "time"
+)
+
var (
Live []string//直播链接
Live_qn string
Cookie string
Title string
Rev float64//营收
+ Live_Start_Time time.Time//直播开始时间
+ Liveing bool//是否在直播
)
//from player-loader-2.0.11.min.js
package F
import (
+ "time"
"strconv"
"strings"
if e := r.S(`"durl":[`, `]`, 0, 0).Err;e == nil {
if urls := p.Json().GetArrayFrom("[" + r.RS + "]", "url");urls != nil {
apilog.W("直播中")
+ c.Liveing = true
o.Live_status = 1
for _,v := range urls {
o.Live = append(o.Live, v.(string))
if e := r.S(`player-loader-`, `.min`, 0, 0).Err;e == nil {
c.VERSION = r.RS
}
+ if e := r.S(`"live_time":"`, `"`, 0, 0).Err;e == nil {
+ c.Live_Start_Time,_ = time.Parse("2006-01-02 15:04:05", r.RS)
+ }
apilog.W("api version", c.VERSION)
}
apilog.W("未在直播")
return
case 1:
+ c.Liveing = true
apilog.W("直播中")
default:
apilog.W("live_status:", live_status)
if i := p.Json().GetValFrom(res, "data.play_url.current_qn"); i != nil {
cu_qn = strconv.Itoa(int(i.(float64)))
}
-
+ if i := p.Json().GetValFrom(res, "data.live_time"); i != nil {
+ c.Live_Start_Time = time.Unix(int64(i.(float64)),0).In(time.FixedZone("UTC-8", -8*60*60))
+ }
if len(qn) != 0 && qn[0] != "0" && qn[0] != "" {
if _,ok := c.Default_qn[qn[0]];!ok{
apilog.W("清晰度未找到", qn[0], ",使用默认")
func ShowRevf(){
if!IsOn("ShowRev") {return}
if ShowRev_start {
- p.Logf().New().Open("danmu.log").Base(1, "Rev").I("营收 ¥", c.Rev)
+ p.Logf().New().Open("danmu.log").Base(1, "Rev").I(fmt.Sprintf("营收 ¥%.2f",c.Rev))
return
}
ShowRev_start = true
for {
- p.Logf().New().Open("danmu.log").Base(1, "Rev").I("营收 ¥", c.Rev)
+ p.Logf().New().Open("danmu.log").Base(1, "Rev").I(fmt.Sprintf("营收 ¥%.2f",c.Rev))
for c.Rev == ShowRev_old {p.Sys().Timeoutf(60)}
ShowRev_old = c.Rev
}
import (
"fmt"
+ "time"
"bytes"
"strconv"
"compress/zlib"
Obs_R(false)
Obsf(false)
Saveflv_wait()
- c.Rev = 0
go ShowRevf()
+ c.Liveing = false
}
if p.Sys().Type(roomid) == "float64" {
Gui_show(Itos([]interface{}{"房间", roomid, "下播了"}), "0room")
Obs_R(true)
go Saveflvf()
}
+ {
+ c.Rev = 0 //营收
+ c.Liveing = true //直播i标志
+ c.Live_Start_Time = time.Now() //开播h时间
+ }
if p.Sys().Type(roomid) == "float64" {
Gui_show(Itos([]interface{}{"房间", roomid, "开播了"}), "0room")
msglog.I("房间", int(roomid.(float64)), "开播了")
"errors"
"time"
"log"
+ "fmt"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
"github.com/gotk3/gotk3/gdk"
p "github.com/qydysky/part"
F "github.com/qydysky/bili_danmu/F"
+ c "github.com/qydysky/bili_danmu/CV"
)
const (
max = 50
var win *gtk.Window
var scrolledwindow0 *gtk.ScrolledWindow
var viewport0 *gtk.Viewport
+ var w2_textView0 *gtk.TextView
+ var w2_textView1 *gtk.TextView
application, err := gtk.ApplicationNew(appId, glib.APPLICATION_FLAGS_NONE)
if err != nil {log.Println(err);return}
builder, err := gtk.BuilderNewFromFile("ui/1.glade")
if err != nil {log.Println(err);return}
+ builder2, err := gtk.BuilderNewFromFile("ui/2.glade")
+ if err != nil {log.Println(err);return}
{
signals := map[string]interface{}{
"on_main_window_destroy": onMainWindowDestroy,
}
builder.ConnectSignals(signals)
+ builder2.ConnectSignals(signals)
}
+
{
obj, err := builder.GetObject("main_window")
if err != nil {log.Println(err);return}
application.AddWindow(win)
defer win.ShowAll()
}
+ {
+ obj, err := builder2.GetObject("main_window")
+ if err != nil {log.Println(err);return}
+ win2, err := isWindow(obj)
+ if err != nil {log.Println(err);return}
+ application.AddWindow(win2)
+ defer win2.ShowAll()
+ }
+ {//营收
+ obj, err := builder2.GetObject("t0")
+ if err != nil {log.Println(err);return}
+ if tmp,ok := obj.(*gtk.TextView); ok {
+ w2_textView0 = tmp
+ }else{log.Println("cant find #t0 in .glade");return}
+ }
+ {//直播时长
+ obj, err := builder2.GetObject("t1")
+ if err != nil {log.Println(err);return}
+ if tmp,ok := obj.(*gtk.TextView); ok {
+ w2_textView1 = tmp
+ }else{log.Println("cant find #t1 in .glade");return}
+ }
{
obj, err := builder.GetObject("scrolledwindow0")
if err != nil {log.Println(err);return}
var e error
if pro_style,e = gtk.CssProviderNew();e == nil{
if e = pro_style.LoadFromPath(`ui/1.css`);e == nil{
- if scr,e := gdk.ScreenGetDefault();e == nil {
+ if scr := win.GetScreen();scr != nil {
gtk.AddProviderForScreen(scr,pro_style,gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
}
}else{log.Println(e)}
})
}
}()
-
+
glib.TimeoutAdd(uint(3000), func()(o bool){
o = true
//y("sssss",load_face(""))
+ {//营收
+ if IsOn("ShowRev") {
+ b,e := w2_textView0.GetBuffer()
+ if e != nil {log.Println(e);return}
+ b.SetText(fmt.Sprintf("¥%.2f",c.Rev))
+ }
+ }
+ {//时长
+ if c.Liveing {
+ b,e := w2_textView1.GetBuffer()
+ if e != nil {log.Println(e);return}
+ d := time.Since(c.Live_Start_Time).Round(time.Second)
+ h := d / time.Hour
+ d -= h * time.Hour
+ m := d / time.Minute
+ d -= m * time.Minute
+ s := d / time.Second
+ b.SetText(fmt.Sprintf("%02d:%02d:%02d", h, m, s))
+ }
+ }
if gtkGetList.Len() == 0 {return}
el := gtkGetList.Front()
if el == nil {return}
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="main_window">
<property name="can_focus">False</property>
+ <property name="title" translatable="yes">弹幕</property>
<property name="window_position">mouse</property>
<property name="default_width">400</property>
<property name="default_height">500</property>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkWindow" id="main_window">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">弹幕机信息</property>
+ <property name="window_position">mouse</property>
+ <property name="default_width">400</property>
+ <property name="default_height">500</property>
+ <property name="destroy_with_parent">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow0">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <child>
+ <object class="GtkViewport" id="viewport0">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkGrid" id="grid0">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="row_spacing">3</property>
+ <property name="column_spacing">2</property>
+ <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">16</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="hexpand">True</property>
+ <property name="label" 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>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTextView" id="t0">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscroll_policy">natural</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">2</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="GtkTextView" id="t1">
+ <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">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>