"iter"
"math"
"strconv"
+ "strings"
"unicode/utf8"
"github.com/dustin/go-humanize"
)
type i interface {
- ToAss(savePath string)
+ ToAss(savePath string, filename ...string)
Init(cfg any)
}
}
}
-func (t *Ass) ToAss(savePath string) {
- f := file.New(savePath+"0.ass", 0, false)
+func (t *Ass) ToAss(savePath string, filename ...string) {
+ f := file.New(savePath+append(filename, "0.ass")[0], 0, false)
defer f.Close()
if f.IsExist() {
_ = f.Delete()
var lsd = make([]float64, lsSize)
var lso = make([]float64, lsSize)
- _, _ = f.Write([]byte(t.header), true)
- for line := range loadCsv(savePath) {
+ var write bool
+ for line := range loadCsv(savePath, strings.Split(append(filename, "0.ass")[0], `.`)[0]+".csv") {
+ if !write {
+ _, _ = f.Write([]byte(t.header), true)
+ write = true
+ }
danmul := utf8.RuneCountInString(line.Text)
danmuSec := (float64(t.showSec*t.fontsize*danmul) / float64(t.fontsize*danmul+playResX))
}
}
-func loadCsv(savePath string) iter.Seq[Data] {
+func loadCsv(savePath string, filename ...string) iter.Seq[Data] {
return func(yield func(Data) bool) {
- csvf := file.New(savePath+"0.csv", 0, false)
+ csvf := file.New(savePath+append(filename, "0.csv")[0], 0, false)
defer csvf.Close()
if !csvf.IsExist() {
func TestMain(t *testing.T) {
var ass = comp.Get[interface {
- ToAss(savePath string)
+ ToAss(savePath string, filename ...string)
Init(cfg any)
}](`ass`)
- ass.ToAss("./testdata/")
+ ass.ToAss("./testdata/", "1.ass")
}
func TestStos(t *testing.T) {
require (
github.com/gotk3/gotk3 v0.6.4
github.com/mdp/qrterminal/v3 v3.2.0
- github.com/qydysky/part v0.28.20250225161111
+ github.com/qydysky/part v0.28.20250302064654
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.22.0 // indirect
github.com/qydysky/biliApi v0.0.0-20240725184407-15076dddb6fb/go.mod h1:om024vfxALQ5vxsbaGoMm8IS0esLYBnEOpJI8FsGoDg=
github.com/qydysky/brotli v0.0.0-20240828134800-e9913a6e7ed9 h1:k451T+bpsLr+Dq9Ujo+Qtx0iomRA1XXS5ttlEojvfuQ=
github.com/qydysky/brotli v0.0.0-20240828134800-e9913a6e7ed9/go.mod h1:cI8/gy/wjy2Eb+p2IUj2ZuDnC8R5Vrx3O0VMPvMvphA=
-github.com/qydysky/part v0.28.20250225161111 h1:34x3k9NeHpP2rfMaq6d5sm3Lru9QdxI3zcXT5JbgUOg=
-github.com/qydysky/part v0.28.20250225161111/go.mod h1:MsSAiZMiWQ5pGP5BCEB3OBsoAPaGykNB7vbeY3mKF2w=
+github.com/qydysky/part v0.28.20250302064654 h1:DpyB2t8PlwClebx2lDsUakDPNaDAXfOXLTzVH3xCb6k=
+github.com/qydysky/part v0.28.20250302064654/go.mod h1:MsSAiZMiWQ5pGP5BCEB3OBsoAPaGykNB7vbeY3mKF2w=
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=