diff options
| author | MkvAutoSubset <[email protected]> | 2021-10-17 20:17:58 +0800 |
|---|---|---|
| committer | Kurenai <[email protected]> | 2021-10-17 20:17:58 +0800 |
| commit | c0f88cb080950879bc8af5cf498ac3aa8a8c68fb (patch) | |
| tree | caa193ee7f100a1b22d5fa7fa8dfe1120f7ae757 /lib | |
| parent | 70a7c4edba281122c05ef46e9efffe5309ef8448 (diff) | |
Bump to 3.1.3
- 增加C函数导出
- 增加python调用的demo
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ass.go | 14 | ||||
| -rw-r--r-- | lib/mkv.go | 14 | ||||
| -rw-r--r-- | lib/shared.go | 20 |
3 files changed, 34 insertions, 14 deletions
@@ -103,14 +103,14 @@ func (self *assProcessor) parse() bool { str += string(_k) } str = strings.TrimSpace(str) - str = reg.ReplaceAllString(str, "") - str += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - reg, _ = regexp.Compile("[1234567890]") - if reg.MatchString(str) { - str = reg.ReplaceAllString(str, "") - str += "1234567890" - } if str != "" { + str = reg.ReplaceAllString(str, "") + str += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + reg, _ = regexp.Compile("[1234567890]") + if reg.MatchString(str) { + str = reg.ReplaceAllString(str, "") + str += "1234567890" + } self.m[k] = new(fontInfo) self.m[k].str = str self.m[k].oldName = k @@ -90,7 +90,7 @@ func (self *mkvProcessor) DumpMKV(file, output string, subset bool) bool { asses = append(asses, f) } if len(asses) > 0 { - if !self.ASSFontSubset(asses, "", "") { + if !self.ASSFontSubset(asses, "", "", false) { ec++ } } @@ -227,7 +227,7 @@ func (self *mkvProcessor) CreateMKVs(vDir, sDir, fDir, tDir, oDir string, slang, tracks := make([]string, 0) if len(asses) > 0 { _ = os.RemoveAll(tDir) - if !self.ASSFontSubset(asses, fDir, "") { + if !self.ASSFontSubset(asses, fDir, "", false) { ec++ } else { __p := path.Join(p, "subsetted") @@ -272,7 +272,7 @@ func (self *mkvProcessor) MakeMKVs(dir, data, output, slang, sttlte string) bool return ec == 0 } -func (self *mkvProcessor) ASSFontSubset(files []string, fonts, output string) bool { +func (self *mkvProcessor) ASSFontSubset(files []string, fonts, output string, dirSafe bool) bool { if len(files) == 0 { return false } @@ -280,15 +280,17 @@ func (self *mkvProcessor) ASSFontSubset(files []string, fonts, output string) bo obj.files = files obj._fonts = fonts obj.output = output - d, _, _, _ := splitPath(obj.files[0]) if obj._fonts == "" { obj._fonts += path.Join(d, "fonts") } if obj.output == "" { - obj.output += path.Join(d, "subsetted") + obj.output = d + dirSafe = true + } + if dirSafe { + obj.output = path.Join(obj.output, "subseted") } - obj.fonts = findFonts(obj._fonts) return obj.parse() && obj.matchFonts() && obj.createFontsSubset() && obj.changeFontsName() && obj.replaceFontNameInAss() diff --git a/lib/shared.go b/lib/shared.go index 215ce7a..b0cfb2f 100644 --- a/lib/shared.go +++ b/lib/shared.go @@ -2,11 +2,15 @@ package mkvlib import ( "log" + "os" "os/exec" + "path/filepath" + "runtime" + "strings" ) const libName = "mkvlib" -const libVer = "1.0.0" +const libVer = "v1.0.2" const LibFName = libName + " " + libVer @@ -14,6 +18,20 @@ var _instance *mkvProcessor func GetInstance() *mkvProcessor { ec := 0 + n := "PATH" + s := ":" + if runtime.GOOS == "windows" { + n = "path" + s = ";" + } + p := os.Getenv(n) + if !strings.HasSuffix(p, s) { + p += s + } + e, _ := os.Executable() + e, _ = filepath.Split(e) + p += e + _ = os.Setenv(n, p) _, _ttx := exec.LookPath(ttx) _, _pyftsubset := exec.LookPath(pyftsubset) _, _mkvextract := exec.LookPath(mkvextract) |
