]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Add 下播总结
authorqydysky <qydysky@foxmail.com>
Tue, 25 Jul 2023 02:50:42 +0000 (10:50 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 25 Jul 2023 02:50:42 +0000 (10:50 +0800)
F/api.go
Reply/F.go
Reply/F/comp.go [new file with mode: 0644]
Reply/F/liveOver/liveOver.go [new file with mode: 0644]
Reply/Reply.go
go.mod
go.sum

index 3f5df117931159b9176d024c72705fc5fc90eb21..1fa6645c0752e6f7430b2524b7e20a20a94e0cd7 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -309,7 +309,9 @@ func (t *GetFunc) Html() (missKey []string) {
                                        t.Roomid = j.RoomInitRes.Data.RoomID
                                }
                                //直播开始时间
-                               t.Live_Start_Time = time.Unix(int64(j.RoomInitRes.Data.LiveTime), 0)
+                               if j.RoomInitRes.Data.LiveTime != 0 {
+                                       t.Live_Start_Time = time.Unix(int64(j.RoomInitRes.Data.LiveTime), 0)
+                               }
                                //是否在直播
                                t.Liveing = j.RoomInitRes.Data.LiveStatus == 1
 
@@ -528,7 +530,9 @@ func (c *GetFunc) getInfoByRoom() (missKey []string) {
                        }
 
                        //直播开始时间
-                       c.Live_Start_Time = time.Unix(int64(j.Data.RoomInfo.LiveStartTime), 0)
+                       if j.Data.RoomInfo.LiveStartTime != 0 {
+                               c.Live_Start_Time = time.Unix(int64(j.Data.RoomInfo.LiveStartTime), 0)
+                       }
                        //是否在直播
                        c.Liveing = j.Data.RoomInfo.LiveStatus == 1
                        //直播间标题
@@ -626,7 +630,9 @@ func (t *GetFunc) getRoomPlayInfo() (missKey []string) {
                        t.Roomid = j.Data.RoomID
                }
                //直播开始时间
-               t.Live_Start_Time = time.Unix(int64(j.Data.LiveTime), 0)
+               if j.Data.LiveTime != 0 {
+                       t.Live_Start_Time = time.Unix(int64(j.Data.LiveTime), 0)
+               }
                //是否在直播
                t.Liveing = j.Data.LiveStatus == 1
 
@@ -719,7 +725,9 @@ func (t *GetFunc) getRoomPlayInfoByQn() (missKey []string) {
                        t.Roomid = j.Data.RoomID
                }
                //直播开始时间
-               t.Live_Start_Time = time.Unix(int64(j.Data.LiveTime), 0)
+               if j.Data.LiveTime != 0 {
+                       t.Live_Start_Time = time.Unix(int64(j.Data.LiveTime), 0)
+               }
                //是否在直播
                t.Liveing = j.Data.LiveStatus == 1
 
index 7a1327f7779d5ca74aa3212b6f0b235fe9e60698..61e91fa0a312f80bff47d4a76f83e2c4611c5079 100644 (file)
@@ -31,6 +31,7 @@ import (
        "github.com/dustin/go-humanize"
        c "github.com/qydysky/bili_danmu/CV"
        F "github.com/qydysky/bili_danmu/F"
+       _ "github.com/qydysky/bili_danmu/Reply/F"
        send "github.com/qydysky/bili_danmu/Send"
 
        p "github.com/qydysky/part"
diff --git a/Reply/F/comp.go b/Reply/F/comp.go
new file mode 100644 (file)
index 0000000..2d71306
--- /dev/null
@@ -0,0 +1,5 @@
+package f
+
+import (
+       _ "github.com/qydysky/bili_danmu/Reply/F/liveOver"
+)
diff --git a/Reply/F/liveOver/liveOver.go b/Reply/F/liveOver/liveOver.go
new file mode 100644 (file)
index 0000000..890e143
--- /dev/null
@@ -0,0 +1,25 @@
+package liveOver
+
+import (
+       "context"
+       "fmt"
+       "time"
+
+       c "github.com/qydysky/bili_danmu/CV"
+       comp "github.com/qydysky/part/component"
+)
+
+func init() {
+       if e := comp.Put[c.Common](`bili_danmu.Reply.wsmsg.preparing.sumup`, sumup); e != nil {
+               panic(e)
+       }
+}
+
+func sumup(ctx context.Context, ptr *c.Common) error {
+       dura := time.Since(ptr.Live_Start_Time).Round(time.Second)
+       if ptr.Live_Start_Time.IsZero() {
+               dura = 0
+       }
+       ptr.Log.Base(`功能`, `下播总结`).L(`I: `, fmt.Sprintf("%d 时长 %s 总营收 ¥%.2f 观看人数 %d", ptr.Roomid, dura, ptr.Rev, ptr.Watched))
+       return nil
+}
index 59981bc01d956dd8c277156cc329cb0ab43210aa..9559cd45f68b10307c48929f5a67069e5bfecdd0 100644 (file)
@@ -3,6 +3,7 @@ package reply
 import (
        "bytes"
        "compress/zlib"
+       "context"
        "encoding/json"
        "fmt"
        "strconv"
@@ -15,6 +16,7 @@ import (
        ws_msg "github.com/qydysky/bili_danmu/Reply/ws_msg"
        send "github.com/qydysky/bili_danmu/Send"
        p "github.com/qydysky/part"
+       comp "github.com/qydysky/part/component"
        mq "github.com/qydysky/part/msgq"
        pstrings "github.com/qydysky/part/strings"
 )
@@ -768,6 +770,10 @@ func (replyF) preparing(s string) {
                        // 停止此房间录制
                        var roomId, _ = strconv.Atoi(type_item.Roomid)
                        StreamOStop(roomId)
+                       // 下播总结
+                       if e := comp.Run(`bili_danmu.Reply.wsmsg.preparing`, context.Background(), c.C); e != nil {
+                               msglog.L(`E: `, e)
+                       }
                }
                Gui_show("房间", type_item.Roomid, "下播了", "0room")
                msglog.L(`I: `, "房间", type_item.Roomid, "下播了")
diff --git a/go.mod b/go.mod
index 242c136b8a88717878a8c3e90ed412ef0304b144..cdfaf538b5201f699ec89c05ec3a5703b8aaf07e 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.20
 require (
        github.com/gotk3/gotk3 v0.6.2
        github.com/mdp/qrterminal/v3 v3.1.1
-       github.com/qydysky/part v0.28.1-0.20230719070824-1cd4290c29fe
+       github.com/qydysky/part v0.28.1-0.20230725023755-f30bbfd028ab
        github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
        github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
        golang.org/x/text v0.11.0
@@ -54,3 +54,5 @@ require (
        modernc.org/sqlite v1.23.1
        rsc.io/qr v0.2.0 // indirect
 )
+
+// replace github.com/qydysky/part => ../part
diff --git a/go.sum b/go.sum
index 136deb8e0277619876ce670f1f971ffb7e4fc22b..d3cfc30424ece0b6011d970c60abd7041a167be7 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -30,8 +30,8 @@ github.com/mdp/qrterminal/v3 v3.1.1/go.mod h1:5lJlXe7Jdr8wlPDdcsJttv1/knsRgzXASy
 github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo=
 github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/qydysky/part v0.28.1-0.20230719070824-1cd4290c29fe h1:5WmdnH9qJ5ytpev9LqKHxCarmu09RLDKRQ4v/ADNgqM=
-github.com/qydysky/part v0.28.1-0.20230719070824-1cd4290c29fe/go.mod h1:CdkAHZ+OxieG1sI4M6UowP9j0QQDnhtDtN4tWsylCPU=
+github.com/qydysky/part v0.28.1-0.20230725023755-f30bbfd028ab h1:f3WoAYWdM4lossSsVpwMCcJ3oIdYHu+2L+svH92AG58=
+github.com/qydysky/part v0.28.1-0.20230725023755-f30bbfd028ab/go.mod h1:CdkAHZ+OxieG1sI4M6UowP9j0QQDnhtDtN4tWsylCPU=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=