]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
23
authorqydysky <qydysky@foxmail.com>
Fri, 25 Sep 2020 09:15:17 +0000 (17:15 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 25 Sep 2020 09:15:17 +0000 (17:15 +0800)
CV/Const.go [moved from Const/Const.go with 95% similarity]
CV/Var.go [moved from Const/Var.go with 100% similarity]
F/F.go
F/api.go [moved from api.go with 97% similarity]
Reply/F.go
Reply/Reply.go
bili_danmu.go
ws.go

similarity index 95%
rename from Const/Const.go
rename to CV/Const.go
index 8d7bbce75dd7b1e5921a5661955fa3954ee4aeea..e9e6b5fe9df6e10abe79acf74bb85cfbb0f36fe8 100644 (file)
@@ -1,5 +1,9 @@
 package constf
 
+const (
+       LogLevel  = 1
+)
+
 //from source/player-loader-2.0.7.min.js L2885
 const (
        WS_OP_HEARTBEAT = 2
similarity index 100%
rename from Const/Var.go
rename to CV/Var.go
diff --git a/F/F.go b/F/F.go
index 937552b25a92531f2ec513b31750de8a8bf5d982..33d8e11c8cbff40fcdd3e844f4a13ee2e68cd42f 100644 (file)
--- a/F/F.go
+++ b/F/F.go
@@ -5,7 +5,7 @@ import (
        "strconv"
 
        p "github.com/qydysky/part"
-       . "github.com/qydysky/bili_danmu/Const"
+       . "github.com/qydysky/bili_danmu/CV"
 )
 
 var flog = p.Logf().New().Open("danmu.log").Base(-1, "F.go")
diff --git a/api.go b/F/api.go
similarity index 97%
rename from api.go
rename to F/api.go
index 75756128b7056980f5c3ed8bde3f4a3b3f162420..07fb5a1d3801ef0404118c4180dd131d7907a9f8 100644 (file)
--- a/api.go
+++ b/F/api.go
@@ -1,8 +1,9 @@
-package bili_danmu
+package F
 
 import (
        "strconv"
 
+       c "github.com/qydysky/bili_danmu/CV"
        p "github.com/qydysky/part"
 )
 
@@ -14,7 +15,7 @@ type api struct {
        Token string
 }
 
-var apilog = p.Logf().New().Base(-1, "api.go").Level(LogLevel)
+var apilog = p.Logf().New().Base(-1, "api.go").Level(c.LogLevel)
 func New_api(Roomid int) (o *api) {
        apilog.Base(-1, "新建")
        defer apilog.Base(0)
index 45ac545fd093df90dada00858bbf275840e8864a..8efacd3f3ccae77168a1336c9f7ca8d83f64b2ad 100644 (file)
@@ -9,7 +9,8 @@ import (
        "time"
        "os/exec"
 
-       c "github.com/qydysky/bili_danmu/Const"
+       c "github.com/qydysky/bili_danmu/CV"
+       F "github.com/qydysky/bili_danmu/F"
        "github.com/christopher-dG/go-obs-websocket"
        p "github.com/qydysky/part"
 )
@@ -106,7 +107,7 @@ var (
        Ass_width = 1280
        Ass_font = 50
        Ass_T = 7
-       Ass_loc = 1//小键盘对应的位置
+       Ass_loc = 7//小键盘对应的位置
 )
 
 var ass = Ass {
@@ -121,21 +122,23 @@ PlayResY: `+strconv.Itoa(Ass_width)+`
 
 [V4+ Styles]
 Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
-Style: Default,,`+strconv.Itoa(Ass_font)+`,&H60FFFFFF,&H000017FF,&H80000000,&H79000000,0,0,0,0,100,100,0,0,1,1,1,`+strconv.Itoa(Ass_loc)+`,15,15,15,1
+Style: Default,,`+strconv.Itoa(Ass_font)+`,&H40FFFFFF,&H000017FF,&H80000000,&H70000000,0,0,0,0,100,100,0,0,1,4,4,`+strconv.Itoa(Ass_loc)+`,20,20,50,1
 
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
 `,
 }
+func Ass_f(file string){
+       ass.file = file
+}
 
-func Assf(s,file string){
+func Assf(s string){
        if !ass.Inuse {return}
-       if file == "" && ass.file == "" {return}
+       if ass.file == "" {return}
 
        if ass.startT.Equal(time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)) {
-               p.Logf().New().Open("danmu.log").Base(1, "Ass").I("弹幕转Ass保存至", file + ".ass")
+               p.Logf().New().Open("danmu.log").Base(1, "Ass").I("弹幕转Ass保存至", ass.file + ".ass")
 
-               ass.file = file
                p.File().FileWR(p.Filel{
                        File:ass.file + ".ass",
                        Write:true,
@@ -154,7 +157,7 @@ func Assf(s,file string){
        // b += "Comment: " + strconv.Itoa(loc) + " "+ Dtos(showedt) + "\n"
        b += `Dialogue: 0,`
        b += Dtos(st) + `,` + Dtos(et)
-       b += `,Default,,0,0,0,,{\fad(500,500)\blur3}` + s + "\n"
+       b += `,Default,,0,0,0,,{\fad(200,500)\blur3}` + s + "\n"
 
        p.File().FileWR(p.Filel{
                File:ass.file + ".ass",
@@ -175,8 +178,8 @@ func Dtos(t time.Duration) string {
 type Saveflv struct {
        Inuse bool
        path string
-       wait chan bool
-       cancel chan interface{}
+       wait chan struct{}
+       cancel chan struct{}
 }
 
 var saveflv = Saveflv {
@@ -185,17 +188,21 @@ var saveflv = Saveflv {
 
 func Saveflvf(){
        if !saveflv.Inuse || saveflv.path != "" {return}
-       l := p.Logf().New().Open("danmu.log").Base(1, "saveflv")
-       defer l.BC()
+       l := p.Logf().New().Open("danmu.log").Base(-1, "saveflv")
+       defer l.Base(0).BC()
 
        if saveflv.path != "" || c.Live == "" {return}
+
+       api := F.New_api(c.Roomid).Get_host_Token().Get_live()
+       c.Live = api.Live
+       
        saveflv.path = strconv.Itoa(c.Roomid) + "_" + time.Now().Format(time.RFC3339)
        l.I("直播流保存到", saveflv.path)
 
-       saveflv.wait = make(chan bool,1)
-       saveflv.cancel = make(chan interface{},1)
+       saveflv.wait = make(chan struct{})
+       saveflv.cancel = make(chan struct{})
        
-       Assf("",saveflv.path)//ass
+       Ass_f(saveflv.path)//ass
        
        rr := p.Req()
        go func(){
@@ -209,8 +216,10 @@ func Saveflvf(){
                SaveToPath:saveflv.path + ".flv",
                Timeout:-1,
        }); e != nil{l.E(e)}
-       Saveflv_transcode()
        l.I("结束")
+       Ass_f("")//ass
+       Saveflv_transcode()
+       l.I("转码结束")
        close(saveflv.wait)
 }
 
@@ -351,23 +360,25 @@ func Autobanf(s string) bool {
        }()
 
        var res []float32
-
-       pt := float32(len([]rune(s)))
-       if pt <= 5 {return false}//字数过少去除
-       res = append(res, pt)
-
-       pt = selfcross(s);
-       if pt > 0.5 {return false}//自身重复高去除
-       res = append(res, pt)
-
-       pt = cross(s, autoban.buf);
-       if pt > 0.7 {return false}//历史重复高去除
-       res = append(res, pt)
-
-       pt = cross(s, autoban.Banbuf);
-       if pt < 0.8 {return false}//ban字符重复低去除
-       res = append(res, pt)
-
+       {
+               pt := float32(len([]rune(s)))
+               if pt <= 5 {return false}//字数过少去除
+               res = append(res, pt)
+       }
+       {       
+               pt := selfcross(s);
+               // if pt > 0.5 {return false}//自身重复高去除
+               // res = append(res, pt)
+
+               pt1 := cross(s, autoban.buf);
+               if pt + pt1 > 0.5 {return false}//历史重复高去除
+               res = append(res, pt, pt1)
+       }
+       {
+               pt := cross(s, autoban.Banbuf);
+               if pt < 0.8 {return false}//ban字符重复低去除
+               res = append(res, pt)
+       }
        l := p.Logf().New().Open("danmu.log").Base(1, "autoban")
        l.W(res).Block()
        return true
index 8f41844dc0e2e23252b51ec6320685975de930a5..9a9801f63e94ff75e01c5d534e1fb5ee28a416ed 100644 (file)
@@ -8,7 +8,7 @@ import (
        p "github.com/qydysky/part"
        F "github.com/qydysky/bili_danmu/F"
        S "github.com/qydysky/bili_danmu/Send"
-       c "github.com/qydysky/bili_danmu/Const"
+       c "github.com/qydysky/bili_danmu/CV"
 )
 
 var replylog = p.Logf().New().Open("danmu.log").Base(-1, "Reply.go")
@@ -81,7 +81,9 @@ func (replyF) special_gift(s string){
        if content != nil {
                sh = append(sh, "节奏风暴", content, "¥ 100")
        }
-
+       {//额外
+               Assf(fmt.Sprintln(sh...))
+       }
        fmt.Println("\n====")
        fmt.Println(sh...)
        fmt.Print("====\n\n")
@@ -105,7 +107,9 @@ func (replyF) guard_buy(s string){
        if price != nil {
                sh = append(sh, "¥", int(price.(float64)) / 1000)
        }
-
+       {//额外 ass
+               Assf(fmt.Sprintln(sh...))
+       }
        fmt.Println("\n====")
        fmt.Println(sh...)
        fmt.Print("====\n\n")
@@ -187,7 +191,9 @@ func (replyF) send_gift(s string){
 
        //小于3万金瓜子
        if allprice < 30000 {msglog.T(sh...);return}
-
+       {//额外
+               Assf(fmt.Sprintln(sh...))
+       }
        fmt.Println("\n====")
        fmt.Println(sh...)
        fmt.Print("====\n\n")
@@ -271,7 +277,9 @@ func (replyF) super_chat_message(s string){
        }
        msglog.Fileonly(true)
        defer msglog.Fileonly(false)
-
+       {//额外
+               Assf(fmt.Sprintln(sh...))
+       }
        fmt.Println("\n====")
        fmt.Println(sh...)
        fmt.Print("====\n\n")
@@ -348,8 +356,8 @@ func (replyF) danmu(s string) {
                {//附加功能 弹幕机 封禁 弹幕合并
                        Danmujif(msg)
                        if Autobanf(msg) {
-                               fmt.Println("风险", msg)
-                               msglog.Base(1, "风险").I(msg)
+                               fmt.Println("风险", auth, ":", msg)
+                               msglog.Base(1, "风险").I(auth, ":", msg)
                                return
                        }
                        if i := Autoskipf(msg, 50, 15); i > 0 {
@@ -373,7 +381,7 @@ func Msg_showdanmu(auth interface{}, msg string) {
                        return
                }
                msg = Shortdanmuf(msg)
-               Assf(msg,"")//ass
+               Assf(msg)//ass
        }
        fmt.Println(msg)
        if auth != nil {msglog.I(auth, ":", msg)}
index 7302da7a24eef55678394d30bcf1943bf5eb118d..8c56ed39783e76130c7078792da0456ed502c04a 100644 (file)
@@ -9,12 +9,11 @@ import (
 
        p "github.com/qydysky/part"
        reply "github.com/qydysky/bili_danmu/Reply"
-       c "github.com/qydysky/bili_danmu/Const"
+       c "github.com/qydysky/bili_danmu/CV"
        F "github.com/qydysky/bili_danmu/F"
 )
 
-const LogLevel = 1
-var danmulog = p.Logf().New().Open("danmu.log").Base(-1, "bili_danmu.go").Level(LogLevel)
+var danmulog = p.Logf().New().Open("danmu.log").Base(-1, "bili_danmu.go").Level(c.LogLevel)
 
 func Demo() {
 
@@ -45,7 +44,7 @@ func Demo() {
                var break_sign bool
                for !break_sign {
                        //获取房间相关信息
-                       api := New_api(room).Get_host_Token().Get_live()
+                       api := F.New_api(room).Get_host_Token().Get_live()
                        if len(api.Url) == 0 || api.Roomid == 0 || api.Token == "" || api.Uid == 0 {
                                danmulog.E("some err")
                                return
diff --git a/ws.go b/ws.go
index 3645acdb29545ce18db596685f4167fe8160dca4..2aa1b660e3117dc91c648c43fa6e18c304376387 100644 (file)
--- a/ws.go
+++ b/ws.go
@@ -5,6 +5,7 @@ import (
 
        "github.com/gorilla/websocket"
 
+       c "github.com/qydysky/bili_danmu/CV"
        p "github.com/qydysky/part"
 )
 
@@ -18,7 +19,7 @@ type ws struct {
 }
 
 func New_ws(url string) (o *ws) {
-       l := p.Logf().New().Base(-1, "ws.go>新建").Level(LogLevel).T("New_ws")
+       l := p.Logf().New().Base(-1, "ws.go>新建").Level(c.LogLevel).T("New_ws")
        defer l.Block()
 
        l.T("ok")
@@ -31,7 +32,7 @@ func New_ws(url string) (o *ws) {
 
 func (i *ws) Handle() (o *ws) {
        o = i
-       l := p.Logf().New().Base(-1, "ws.go>处理").Level(LogLevel).T("*ws.handle")
+       l := p.Logf().New().Base(-1, "ws.go>处理").Level(c.LogLevel).T("*ws.handle")
        defer l.Block()
 
        if o.used {
@@ -118,7 +119,7 @@ func (i *ws) Handle() (o *ws) {
 
 func (i *ws) Heartbeat(Millisecond int, msg []byte) (o *ws) {
        o = i
-       l := p.Logf().New().Base(-1, "ws.go>心跳").Level(LogLevel).T("*ws.heartbeat")
+       l := p.Logf().New().Base(-1, "ws.go>心跳").Level(c.LogLevel).T("*ws.heartbeat")
        defer l.Block()
 
        if !o.used {
@@ -147,7 +148,7 @@ func (i *ws) Heartbeat(Millisecond int, msg []byte) (o *ws) {
 }
 
 func (o *ws) Close() {
-       l := p.Logf().New().Base(-1, "ws.go>关闭").Level(LogLevel)
+       l := p.Logf().New().Base(-1, "ws.go>关闭").Level(c.LogLevel)
        defer l.Block()
 
        if !o.used {