]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Improve 版本显示到state
authorqydysky <qydysky@foxmail.com>
Mon, 1 Jan 2024 15:36:25 +0000 (23:36 +0800)
committerqydysky <qydysky@foxmail.com>
Mon, 1 Jan 2024 15:36:25 +0000 (23:36 +0800)
.github/workflows/go.yml
.github/workflows/test.yml
CV/VERSION [moved from VERSION with 100% similarity]
CV/Var.go
F/F.go
README.md
Reply/stream.go
bili_danmu.go
go.mod
go.sum

index 0ca4ff1e88592b9e178912f35bb22c4fa76d2502..44419bb20a1caf5a8f4702b8de3c5d30e963803d 100644 (file)
@@ -5,7 +5,7 @@ on:
     branches:
     - 'master'
     paths:
-    - 'VERSION'
+    - 'CV/VERSION'
 
 jobs:
   buildtest:
@@ -72,7 +72,7 @@ jobs:
       run: |
         sudo apt-get update
         sudo apt-get install libgtk-3-dev libcairo2-dev libglib2.0-dev
-        git rev-parse --short HEAD > VERSION
+        git rev-parse --short HEAD > CV/VERSION
         cd demo
         go get .
         CGO_ENABLED=0 go build -pgo=auto -v -buildmode=exe -o demo.run main.go
@@ -111,7 +111,7 @@ jobs:
 
     - name: Build
       run: |
-        git rev-parse --short HEAD > VERSION
+        git rev-parse --short HEAD > CV/VERSION
         cd demo
         set CGO_ENABLED=0
         go get .
index 87601af98541decfb09b8037a765f8f8a9c73c50..33a43a72bb9ff77e3cede2fda68c4a28229ea20f 100644 (file)
@@ -74,7 +74,7 @@ jobs:
 
     - name: Build
       run: |
-        git rev-parse --short HEAD > VERSION
+        git rev-parse --short HEAD > CV/VERSION
         cd demo
         sudo apt-get update
         sudo apt-get install libgtk-3-dev libcairo2-dev libglib2.0-dev
@@ -113,7 +113,7 @@ jobs:
 
     - name: Build
       run: |
-        git rev-parse --short HEAD > VERSION
+        git rev-parse --short HEAD > CV/VERSION
         cd demo
         go get .
         set CGO_ENABLED=0
similarity index 100%
rename from VERSION
rename to CV/VERSION
index e4192b113dd93d38db126bc8c7c0154d12d9f03f..b782dcf667af6c3155eaf573dde54effeab06bca 100644 (file)
--- a/CV/Var.go
+++ b/CV/Var.go
@@ -3,6 +3,7 @@ package cv
 import (
        "context"
        "database/sql"
+       _ "embed"
        "encoding/json"
        "errors"
        "flag"
@@ -31,6 +32,9 @@ import (
        _ "modernc.org/sqlite"
 )
 
+//go:embed VERSION
+var version string
+
 type StreamType struct {
        Protocol_name string
        Format_name   string
@@ -39,6 +43,7 @@ type StreamType struct {
 
 type Common struct {
        PID               int                   `json:"pid"`           //进程id
+       Version           string                `json:"version"`       //版本
        Uid               int                   `json:"-"`             //client uid
        Live              []LiveQn              `json:"-"`             //直播流链接
        Live_qn           int                   `json:"liveQn"`        //当前直播流质量
@@ -119,6 +124,7 @@ func (t *Common) IsOn(key string) bool {
 func (t *Common) Copy() *Common {
        var c = Common{
                PID:               t.PID,
+               Version:           t.Version,
                Uid:               t.Uid,
                Live:              t.Live,
                Live_qn:           t.Live_qn,
@@ -197,6 +203,7 @@ func (t *Common) ValidLive() *LiveQn {
 
 func (t *Common) Init() *Common {
        t.PID = os.Getpid()
+       t.Version = version
        t.StartT = time.Now()
 
        t.AllStreamType = map[string]StreamType{
@@ -381,20 +388,21 @@ func (t *Common) Init() *Common {
                                        gcAvgS = time.Since(t.StartT).Seconds() / float64(memStats.NumGC)
                                }
 
-                               reqState := t.ReqPool.PoolState()
+                               reqState := t.ReqPool.State()
 
                                ResStruct{0, "ok", map[string]any{
+                                       "version":     strings.TrimSpace(t.Version),
                                        "startTime":   t.StartT.Format(time.DateTime),
                                        "currentTime": time.Now().Format(time.DateTime),
                                        "state": map[string]any{
                                                "base": map[string]any{
                                                        "reqPoolState": map[string]any{
-                                                               "pooled":   reqState[0],
-                                                               "nopooled": reqState[1],
-                                                               "inuse":    reqState[2],
-                                                               "nouse":    reqState[3],
-                                                               "sum":      reqState[4],
-                                                               "qts":      math.Round(reqState[5].(float64)*100) / 100,
+                                                               "pooled":   reqState.Pooled,
+                                                               "nopooled": reqState.Nopooled,
+                                                               "inuse":    reqState.Inuse,
+                                                               "nouse":    reqState.Nouse,
+                                                               "sum":      reqState.Sum,
+                                                               "qts":      math.Round(reqState.GetPerSec*100) / 100,
                                                        },
                                                        "numGoroutine": runtime.NumGoroutine(),
                                                        "goVersion":    runtime.Version(),
diff --git a/F/F.go b/F/F.go
index c7ca5f1033c36a45f7e7447854ae4e9c59ce7a63..34d3ed05e74471ad1489bbb4710a3ec67d49c332 100644 (file)
--- a/F/F.go
+++ b/F/F.go
@@ -65,8 +65,13 @@ func HelloGen(roomid int, key string) []byte {
 
        var obj = `{"uid":` + strconv.Itoa(c.C.Uid) +
                `,"roomid":` + strconv.Itoa(roomid) +
-               `,"protover":` + strconv.Itoa(c.Protover) +
-               `,"platform":"` + c.Platform +
+               `,"protover":` + strconv.Itoa(c.Protover)
+
+       if buvid, ok := c.C.Cookie.LoadV("buvid3").(string); ok {
+               obj += `,"buvid":"` + buvid + `"`
+       }
+
+       obj += `,"platform":"` + c.Platform +
                // `","clientver":"` + c.VERSION + //delete at 2021 4 14
                `","type":` + strconv.Itoa(c.Type) +
                `,"key":"` + key + `"}`
index 5647d1ccb5009b694948748960b27883c371a403..aed86e0c01a60c4d39048ec4b57bbc252ff715bc 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,7 +1,6 @@
 ## bilibili 直播弹幕机
 [![Go Report Card](https://goreportcard.com/badge/github.com/qydysky/bili_danmu)](https://goreportcard.com/report/github.com/qydysky/bili_danmu)
 [![codecov](https://codecov.io/gh/qydysky/bili_danmu/branch/master/graph/badge.svg?token=2R7031P47C)](https://codecov.io/gh/qydysky/bili_danmu)
-[![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/qydysky/bili_danmu)](https://libraries.io/go/github.com%2Fqydysky%2Fbili_danmu)
 [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fqydysky%2Fbili_danmu.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Fqydysky%2Fbili_danmu?ref=badge_small)
 [![少年Pi的直播回放](https://img.shields.io/website?up_message=%E5%9C%A8%E7%BA%BF&down_message=%E7%A6%BB%E7%BA%BF&url=http%3A%2F%2F8.134.76.53%3A8080%2Fweb%2F&label=%E5%B0%91%E5%B9%B4Pi%E7%9A%84%E7%9B%B4%E6%92%AD%E5%9B%9E%E6%94%BE)](https://r.qydysky.org/bili)
 
index 1631e59393236fac16c36c569c5bdafda1ac0ee4..d4249e21563392ea57274202092e3a8102ae750d 100644 (file)
@@ -884,7 +884,9 @@ func (t *M4SStream) saveStreamM4s() (e error) {
                                        return
                                case <-ticker.C:
                                }
-                               t.log.L(`T: `, fmt.Sprintf("m4sPoolState pooled/no(%d/%d), inuse/no(%d/%d), sum(%d), qts(%.2f)", t.m4s_pool.PoolState()...))
+                               reqState := t.m4s_pool.State()
+                               t.log.L(`T: `, fmt.Sprintf("m4sPoolState pooled/no(%d/%d), inuse/no(%d/%d), sum(%d), qts(%.2f)",
+                                       reqState.Pooled, reqState.Nopooled, reqState.Inuse, reqState.Nouse, reqState.Sum, reqState.GetPerSec))
                        }
                }()
        }
index c94dde005f51c3c3176d37639eeca8ec7207b031..cbccb95f0a5fdda4c747225d6f98f04b130db9fe 100644 (file)
@@ -9,7 +9,6 @@ import (
        "os"
        "os/signal"
        "strconv"
-       "strings"
        "time"
 
        c "github.com/qydysky/bili_danmu/CV"
@@ -28,13 +27,10 @@ import (
        ws "github.com/qydysky/part/websocket"
 )
 
-//go:embed VERSION
-var version string
-
 func Start() {
        danmulog := c.C.Log.Base(`bilidanmu`)
        danmulog.L(`I: `, `当前PID:`, c.C.PID)
-       danmulog.L(`I: `, "version: ", strings.TrimSpace(version))
+       danmulog.L(`I: `, "version: ", c.C.Version)
 
        //检查配置
        if c.C.K_v.Len() == 0 {
diff --git a/go.mod b/go.mod
index 410092a3dabd9400e4bc3c1077fbf7ce0e2a5572..0d61f57f0712baf2aea6ab1258f075b77ab2e2fb 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.21
 require (
        github.com/gotk3/gotk3 v0.6.2
        github.com/mdp/qrterminal/v3 v3.2.0
-       github.com/qydysky/part v0.28.20231215215733
+       github.com/qydysky/part v0.28.20240101151147
        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.14.0
diff --git a/go.sum b/go.sum
index 6c45799fd60054e9a7019bd761d470ef790d4614..84dd7d84fdde9035cf46fca67ad72ae1b6f8c0d9 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -35,8 +35,8 @@ github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
 github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/qydysky/part v0.28.20231215215733 h1:qxbqSdoLUBG6o2VkKxM1IAaXoCQZcgLcmierFW9zwvc=
-github.com/qydysky/part v0.28.20231215215733/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
+github.com/qydysky/part v0.28.20240101151147 h1:ugiSjvUjGWjdWGN3nJppcNAxGPHccFkUtDTcqnfUvJ4=
+github.com/qydysky/part v0.28.20240101151147/go.mod h1:NyKyjpBCSjcHtKlC+fL5lCidm57UCnwEgufiBDs5yxA=
 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=