]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
ass编码
authorqydysky <qydysky@foxmail.com>
Fri, 11 Jun 2021 15:50:14 +0000 (23:50 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 11 Jun 2021 15:50:14 +0000 (23:50 +0800)
F/CookieCrypo.go
Reply/F.go
demo/go.mod
demo/go.sum
go.mod
go.sum

index 1a6d314677dfb81a8ee4ca53a8bf302bbef2fe43..4697bea4dbfb84ad7d8aaa0851934bf4536fcbba 100644 (file)
@@ -74,7 +74,6 @@ func CookieSet(source []byte) {
                        f := p.File()
                        f.FileWR(p.Filel{
                                File:`cookie.txt`,
-                               Write:true,
                                Loc:0,
                                Context:[]interface{}{`nol`,source},
                        })
@@ -88,7 +87,6 @@ func CookieSet(source []byte) {
                f := p.File()
                f.FileWR(p.Filel{
                        File:`cookie.txt`,
-                       Write:true,
                        Loc:0,
                        Context:[]interface{}{`pem`,source},
                })
index 6fb5345e38bf1145304f685408258822f49620f1..b661bd48ab8c7c4be70eb225ed4557cd3a574ae5 100644 (file)
@@ -132,7 +132,7 @@ type Ass struct {
        file string//弹幕ass文件名
        startT time.Time//开始记录的基准时间
        header string//ass开头
-       encoderS func(string)(string,error)//编码
+       wrap func(io.Writer)(io.Writer)//编码
 }
 
 var (
@@ -159,7 +159,7 @@ Style: Default,,`+strconv.Itoa(Ass_font)+`,&H40FFFFFF,&H000017FF,&H80000000,&H40
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
 `,
-encoderS:simplifiedchinese.GB18030.NewEncoder().String,
+wrap:simplifiedchinese.GB18030.NewEncoder().Writer,
 }
 
 func init(){
@@ -171,9 +171,7 @@ func init(){
                if v1,ok := accept[v];ok && v1 {
                        c.Log.Base(`Ass`).L(`T: `,"编码:", v)
                        if v == `utf-8` {
-                               ass.encoderS = func(b string)(string,error){
-                                       return b,nil
-                               }
+                               ass.wrap = nil
                        }
                }
        }
@@ -190,18 +188,13 @@ func Ass_f(file string, st time.Time){
                c.Log.Base(`Ass`).L(`I: `, "保存到", ass.file + ".ass")
                c.Log.Base(`Ass`).L(`W: `, err)
        }
-
-       if tmp,err := ass.encoderS(ass.header);err != nil {
-               c.Log.Base(`Ass`).L(`W: `, err)
-       } else {
-               p.File().FileWR(p.Filel{
-                       File:ass.file + ".ass",
-                       Write:true,
-                       Loc:0,
-                       Context:[]interface{}{tmp},
-               })
-               ass.startT = st
-       }
+       p.File().FileWR(p.Filel{
+               File:ass.file + ".ass",
+               Loc:0,
+               Context:[]interface{}{ass.header},
+               WrapWriter:ass.wrap,
+       })
+       ass.startT = st
 }
 
 //传入要显示的单条字幕
@@ -219,17 +212,12 @@ func Assf(s string){
        b += `Dialogue: 0,`
        b += dtos(st) + `,` + dtos(et)
        b += `,Default,,0,0,0,,{\fad(200,500)\blur3}` + s + "\n"
-
-       if tmp,err := ass.encoderS(b);err != nil {
-               c.Log.Base(`Ass`).L(`W: `, err)
-       } else {
-               p.File().FileWR(p.Filel{
-                       File:ass.file + ".ass",
-                       Write:true,
-                       Loc:-1,
-                       Context:[]interface{}{tmp},
-               })
-       }
+       p.File().FileWR(p.Filel{
+               File:ass.file + ".ass",
+               Loc:-1,
+               Context:[]interface{}{b},
+               WrapWriter:ass.wrap,
+       })
 }
 
 //时间转化为0:00:00.00规格字符串
@@ -1270,7 +1258,6 @@ func Savestreamf(){
                                f := p.File()
                                f.FileWR(p.Filel{
                                        File:savestream.path+"0.m3u8.dtmp",
-                                       Write:true,
                                        Loc:-1,
                                        Context:[]interface{}{file_add},
                                })
@@ -1340,7 +1327,6 @@ func Savestreamf(){
                                f := p.File()
                                f.FileWR(p.Filel{
                                        File:savestream.path+"0.m3u8.dtmp",
-                                       Write:true,
                                        Loc:-1,
                                        Context:[]interface{}{"#EXT-X-ENDLIST"},
                                })
@@ -1906,7 +1892,6 @@ func Save_to_json(Loc int,Context []interface{}) {
        if path,ok := c.K_v.LoadV(`save_to_json`).(string);ok && path != ``{
                p.File().FileWR(p.Filel{
                        File:path,
-                       Write:true,
                        Loc:int64(Loc),
                        Context:Context,
                })
index 77000cc05ce1aaf29983a082e432ce9bd464521d..c5d20090142f790b761f5518f5baefe54c0b6231 100644 (file)
@@ -14,7 +14,7 @@ require (
        github.com/miekg/dns v1.1.42 // indirect
        github.com/mitchellh/mapstructure v1.4.1 // indirect
        github.com/qydysky/bili_danmu v0.5.9
-       github.com/qydysky/part v0.5.22 // indirect
+       github.com/qydysky/part v0.5.23 // indirect
        github.com/shirou/gopsutil v3.21.5+incompatible // indirect
        github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
        github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
index ccc707a25a706b302dba82ba18c1c7cb14f36805..4f5ac514dfbd5e96f1740237228413555fe51584 100644 (file)
@@ -306,6 +306,8 @@ github.com/qydysky/part v0.5.21 h1:YttjojBT2w7ys8pc5kfHis4a2+aMRMYJXb+sOi+RWmU=
 github.com/qydysky/part v0.5.21/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
 github.com/qydysky/part v0.5.22 h1:KPaREUPSHidO/W9Blp708BSi7oqOfOE467+Tid6x25U=
 github.com/qydysky/part v0.5.22/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
+github.com/qydysky/part v0.5.23 h1:JaP+t+ILHScJh7FPE6AUPqrkdMhfRIXSgAetJNPFTp0=
+github.com/qydysky/part v0.5.23/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
 github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad h1:Jtzf509lQrkUMGTV0Sc6IDCAiR1VrBcHrIban7hpye4=
 github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad/go.mod h1:w32TkJNVtTJd4LOS09cq+4uYG6itcN2vsqw+slp44Rg=
 github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba h1:1ew9dRpc0Rux0WkWeT/4AE15ynYWmL2D7onJEJIFOB8=
diff --git a/go.mod b/go.mod
index 35923c120724ad7668a415dd09fe2b9d0b126ac2..a737b5fed790664db909a5b763444705f542e606 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,7 @@ require (
        github.com/mdp/qrterminal/v3 v3.0.0
        github.com/miekg/dns v1.1.42 // indirect
        github.com/mitchellh/mapstructure v1.4.1 // indirect
-       github.com/qydysky/part v0.5.22
+       github.com/qydysky/part v0.5.23
        github.com/shirou/gopsutil v3.21.5+incompatible // indirect
        github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
        github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
diff --git a/go.sum b/go.sum
index 462ae7840de1e59fe458e80d3b61ad49302fe915..86e41919bd23373edfcec97f2ed19e88fd489e7f 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -80,6 +80,8 @@ github.com/qydysky/part v0.5.21 h1:YttjojBT2w7ys8pc5kfHis4a2+aMRMYJXb+sOi+RWmU=
 github.com/qydysky/part v0.5.21/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
 github.com/qydysky/part v0.5.22 h1:KPaREUPSHidO/W9Blp708BSi7oqOfOE467+Tid6x25U=
 github.com/qydysky/part v0.5.22/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
+github.com/qydysky/part v0.5.23 h1:JaP+t+ILHScJh7FPE6AUPqrkdMhfRIXSgAetJNPFTp0=
+github.com/qydysky/part v0.5.23/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
 github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba h1:1ew9dRpc0Rux0WkWeT/4AE15ynYWmL2D7onJEJIFOB8=
 github.com/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba/go.mod h1:w32TkJNVtTJd4LOS09cq+4uYG6itcN2vsqw+slp44Rg=
 github.com/shirou/gopsutil v2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=