summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorac79b0c6 <[email protected]>2022-12-12 12:55:35 +0800
committerac79b0c6 <[email protected]>2022-12-12 12:55:35 +0800
commit9e5efd8c0622311f7665a2354f7326f14d7deb83 (patch)
tree3645b9b3c532966c9e14bfdab3c5bf213125d05d
parentba0c9793a1ab342b3527ed60652a513ec84bc677 (diff)
update mkvlib:fix bug.
-rw-r--r--mkvlib/ass.go87
-rw-r--r--mkvlib/shared.go2
2 files changed, 47 insertions, 42 deletions
diff --git a/mkvlib/ass.go b/mkvlib/ass.go
index 678787b..68dfd1e 100644
--- a/mkvlib/ass.go
+++ b/mkvlib/ass.go
@@ -129,10 +129,11 @@ func (self *assProcessor) parse() bool {
}
if ec == 0 {
opt := parser.SSAOptions{}
- reg, _ := regexp.Compile(`\\fn@?([^\r\n\\\}]*)`)
- _reg, _ := regexp.Compile(`\\([bir])([^\r\n\\\}]*)`)
- __reg, _ := regexp.Compile(`nd[xyz]?\d+`)
- ___reg, _ := regexp.Compile(`\d`)
+ reg, _ := regexp.Compile(`\\[^\r\n\\\}]+`)
+ _reg, _ := regexp.Compile(`\\fn@?(.+)`)
+ __reg, _ := regexp.Compile(`\\([bir])(.*)`)
+ ___reg, _ := regexp.Compile(`nd[xyz]?\d+`)
+ ____reg, _ := regexp.Compile(`\d`)
m := make(map[string]string)
for k, v := range self.subtitles {
subtitle, err := parser.ReadFromSSAWithOptions(strings.NewReader(v), opt)
@@ -148,45 +149,49 @@ func (self *assProcessor) parse() bool {
for _, _item := range item.Lines {
for _, __item := range _item.Items {
if __item.InlineStyle != nil {
- arr := reg.FindStringSubmatch(__item.InlineStyle.SSAEffect)
- if len(arr) > 1 {
- name = arr[1]
- }
- _arr := _reg.FindAllStringSubmatch(__item.InlineStyle.SSAEffect, -1)
- for _, v := range _arr {
- if len(v) > 2 {
- switch v[1] {
- case "b":
- i, err := strconv.Atoi(v[2])
- if err == nil {
- if i == 0 || (i > 1 && i < 612) {
- _b = false
- } else if i == 1 || i > 611 {
- _b = true
+ items := reg.FindAllString(__item.InlineStyle.SSAEffect, -1)
+ for _, ___item := range items {
+ arr := _reg.FindStringSubmatch(___item)
+ if len(arr) > 1 {
+ name = arr[1]
+ continue
+ }
+ _arr := __reg.FindAllStringSubmatch(___item, -1)
+ for _, v := range _arr {
+ if len(v) > 2 {
+ switch v[1] {
+ case "b":
+ i, err := strconv.Atoi(v[2])
+ if err == nil {
+ if i == 0 || (i > 1 && i < 612) {
+ _b = false
+ } else if i == 1 || i > 611 {
+ _b = true
+ }
+ }
+ break
+ case "i":
+ _i = v[2] == "1"
+ break
+ case "r":
+ if ___reg.MatchString(v[2]) {
+ break
+ }
+ v[2] = strings.TrimPrefix(v[2], "*")
+ if v[2] == "" {
+ name = ""
+ _b = *item.Style.InlineStyle.SSABold
+ _i = *item.Style.InlineStyle.SSAItalic
+ } else if s, ok := subtitle.Styles[v[2]]; ok {
+ name = s.InlineStyle.SSAFontName
+ _b = *s.InlineStyle.SSABold
+ _i = *s.InlineStyle.SSAItalic
+ } else {
+ printLog(self.lcb, logError, `Not found style in the ass file:"%s" [%s].`, k, v[2])
+ ec++
}
- }
- break
- case "i":
- _i = v[2] == "1"
- break
- case "r":
- if __reg.MatchString(v[2]) {
break
}
- v[2] = strings.TrimPrefix(v[2], "*")
- if v[2] == "" {
- name = ""
- _b = *item.Style.InlineStyle.SSABold
- _i = *item.Style.InlineStyle.SSAItalic
- } else if s, ok := subtitle.Styles[v[2]]; ok {
- name = s.InlineStyle.SSAFontName
- _b = *s.InlineStyle.SSABold
- _i = *s.InlineStyle.SSAItalic
- } else {
- printLog(self.lcb, logError, `Not found style in the ass file:"%s" [%s].`, k, v[2])
- ec++
- }
- break
}
}
}
@@ -216,7 +221,7 @@ func (self *assProcessor) parse() bool {
self.m = make(map[string]*fontInfo)
for k, v := range m {
if v != "" {
- if ___reg.MatchString(v) {
+ if ____reg.MatchString(v) {
v += "0123456789"
}
v += "a\u0020\u00a0"
diff --git a/mkvlib/shared.go b/mkvlib/shared.go
index 78706a7..4284c91 100644
--- a/mkvlib/shared.go
+++ b/mkvlib/shared.go
@@ -12,7 +12,7 @@ import (
)
const libName = "mkvlib"
-const libVer = "v2.2.0"
+const libVer = "v2.2.1"
const LibFName = libName + " " + libVer