From: qydysky Date: Thu, 6 Feb 2025 17:04:45 +0000 (+0800) Subject: Improve 弹幕分值默认统计弹幕数 (#162) X-Git-Tag: v0.15.7~4 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=299de5bf7dbe4b892c1dd1386e1eb069a43cc808;p=bili_danmu%2F.git Improve 弹幕分值默认统计弹幕数 (#162) --- diff --git a/Reply/F/danmuCountPerMin/danmuCountPerMin.go b/Reply/F/danmuCountPerMin/danmuCountPerMin.go index b0a1830..2b7cfc5 100644 --- a/Reply/F/danmuCountPerMin/danmuCountPerMin.go +++ b/Reply/F/danmuCountPerMin/danmuCountPerMin.go @@ -72,6 +72,14 @@ func (t *danmuCountPerMin) Rec(ctx context.Context, rid int, savePath string) fu cfgMsg := make(map[*regexp.Regexp]int) cfgUid := make(map[string]int) + if cfg == nil { // 默认统计弹幕数 + cfg = map[string]any{ + `danmu`: map[string]any{ + `.`: 1.0, + }, + } + } + if m, ok := cfg["danmu"].(map[string]any); ok { for k, v := range m { if point, ok := v.(float64); ok && point != 0 { diff --git a/Reply/stream.go b/Reply/stream.go index 5793212..5c75d92 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -1406,9 +1406,7 @@ func (t *M4SStream) Start() bool { startf := func(_ *M4SStream) error { l.L(`T: `, `开始`) //弹幕分值统计 - if m, ok := ms.common.K_v.LoadV("弹幕分值").(map[string]any); ok { - replyFunc.DanmuCountPerMin.Rec(contextC, ms.common.Roomid, ms.GetSavePath())(m) - } + replyFunc.DanmuCountPerMin.Rec(contextC, ms.common.Roomid, ms.GetSavePath())(ms.common.K_v.LoadV("弹幕分值").(map[string]any)) return nil } stopf := func(_ *M4SStream) error { diff --git a/demo/config/config_K_v.json b/demo/config/config_K_v.json index 9595140..04ea298 100644 --- a/demo/config/config_K_v.json +++ b/demo/config/config_K_v.json @@ -234,7 +234,7 @@ "env": "" } ], - "弹幕分值-help":"对每条弹幕进行评分,每分钟输出分值到danmuCountPerMin.json,无有效规则时不生成json,用于后续评估", + "弹幕分值-help":"对每条弹幕进行评分,每分钟输出分值到danmuCountPerMin.json,无有效规则时默认统计弹幕数,用于后续评估", "弹幕分值":{ "danmu-help":"key为正则表达式,匹配成功时分值加value,value为0时忽略", "danmu": {