summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorac79b0c6 <[email protected]>2022-06-06 10:54:06 +0800
committerac79b0c6 <[email protected]>2022-06-06 10:54:06 +0800
commit764408a7e7016905525a9f0eeabdb59f2af3aa6b (patch)
treed0a0ac95eeb598f1ce977c980b3b517505d60ea5
parent765e5e9bd2431b132cd3e6cfffa0df44eb531d05 (diff)
update
-rw-r--r--mkvlib/ass.go52
-rw-r--r--mkvlib/ass2pgs.go2
-rw-r--r--mkvlib/go.mod4
-rw-r--r--mkvlib/mkv.go40
-rw-r--r--mkvlib/shared.go35
-rw-r--r--mkvtool/main.go38
6 files changed, 98 insertions, 73 deletions
diff --git a/mkvlib/ass.go b/mkvlib/ass.go
index 07a8e4e..0735060 100644
--- a/mkvlib/ass.go
+++ b/mkvlib/ass.go
@@ -106,7 +106,7 @@ func (self *assProcessor) parse() bool {
}
}
if ec > 0 {
- printLog(self.lcb, LogError, `Failed to read the ass file: "%s"`, file)
+ PrintLog(self.lcb, LogError, `Failed to read the ass file: "%s"`, file)
}
_ = f.Close()
}
@@ -121,7 +121,7 @@ func (self *assProcessor) parse() bool {
subtitle, err := parser.ReadFromSSAWithOptions(strings.NewReader(v), opt)
if err != nil {
ec++
- printLog(self.lcb, LogError, `Failed to parse the ass file: "%s" [%s]`, k, err)
+ PrintLog(self.lcb, LogError, `Failed to parse the ass file: "%s" [%s]`, k, err)
continue
}
for _, item := range subtitle.Items {
@@ -164,7 +164,7 @@ func (self *assProcessor) parse() bool {
_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])
+ PrintLog(self.lcb, LogError, `Not found style in the ass file:"%s" [%s].`, k, v[2])
ec++
}
break
@@ -207,7 +207,7 @@ func (self *assProcessor) parse() bool {
}
}
if len(self.m) == 0 {
- printLog(self.lcb, LogWarning, `Not found item in the ass file(s): "%d"`, len(self.files))
+ PrintLog(self.lcb, LogWarning, `Not found item in the ass file(s): "%d"`, len(self.files))
}
}
return ec == 0
@@ -250,7 +250,7 @@ func (self *assProcessor) dumpFont(file, out string) bool {
}
}
if !ok {
- printLog(self.lcb, LogError, `Failed to dump font: "%s".`, n)
+ PrintLog(self.lcb, LogError, `Failed to dump font: "%s".`, n)
}
return ok
}
@@ -308,7 +308,7 @@ func (self *assProcessor) getFontName(p string) [][]map[string]bool {
_f, err := c.Font(i)
if err == nil {
if g, _ := _f.GlyphIndex(nil, '\u0020'); g == 0 {
- printLog(self.lcb, LogWarning, `Font: "%s"[%d] is not defined '\u0020',skip.`, p, i)
+ PrintLog(self.lcb, LogWarning, `Font: "%s"[%d] is not defined '\u0020',skip.`, p, i)
} else {
fonts = append(fonts, _f)
}
@@ -319,7 +319,7 @@ func (self *assProcessor) getFontName(p string) [][]map[string]bool {
_f, err := sfnt.Parse(data)
if err == nil {
if g, _ := _f.GlyphIndex(nil, '\u0020'); g == 0 {
- printLog(self.lcb, LogWarning, `Font: "%s" is not defined '\u0020',skip.`, p)
+ PrintLog(self.lcb, LogWarning, `Font: "%s" is not defined '\u0020',skip.`, p)
} else {
fonts = append(fonts, _f)
}
@@ -402,7 +402,7 @@ func (self *assProcessor) checkFontMissing(f *fontInfo, i int, c bool) bool {
}
if _str != "" {
_str = stringDeduplication(_str)
- printLog(self.lcb, LogWarning, `{%s%02d}Font [%s] -> "%s"[%d] missing normal char(s): "%s"`, h, i, f.oldName, f.file, f.index, _str)
+ PrintLog(self.lcb, LogWarning, `{%s%02d}Font [%s] -> "%s"[%d] missing normal char(s): "%s"`, h, i, f.oldName, f.file, f.index, _str)
}
if len(_runes) > 0 {
_str = ""
@@ -410,7 +410,7 @@ func (self *assProcessor) checkFontMissing(f *fontInfo, i int, c bool) bool {
_str += fmt.Sprintf(`,0x%x`, _rune)
}
_str = _str[1:]
- printLog(self.lcb, LogWarning, `{%s%02d}Font [%s] -> "%s"[%d] missing special char(s): "%s"`, h, i, f.oldName, f.file, f.index, _str)
+ PrintLog(self.lcb, LogWarning, `{%s%02d}Font [%s] -> "%s"[%d] missing special char(s): "%s"`, h, i, f.oldName, f.file, f.index, _str)
}
return _str == "" && len(_runes) == 0
}
@@ -428,7 +428,7 @@ func (self *assProcessor) matchFonts() []string {
}
if fb > 0 && _k[1] != "Regular" {
if fb == 1 {
- printLog(self.lcb, LogWarning, `Font fallback:[%s^%s] -> [%s^Regular]`, _k[0], _k[1], _k[0])
+ PrintLog(self.lcb, LogWarning, `Font fallback:[%s^%s] -> [%s^Regular]`, _k[0], _k[1], _k[0])
}
_k[1] = "Regular"
}
@@ -479,7 +479,7 @@ func (self *assProcessor) matchFonts() []string {
for k, _ := range self.m {
if self.m[k].file == "" {
el = append(el, k)
- printLog(self.lcb, LogError, `Missing the font: "%s".`, k)
+ PrintLog(self.lcb, LogError, `Missing the font: "%s".`, k)
}
}
return el
@@ -529,12 +529,12 @@ func (self *assProcessor) matchFontName(m []map[string]bool, _k []string, b bool
fmailies = append(fmailies, family)
}
if len(fmailies) > 1 {
- printLog(self.lcb, LogSWarning, `Font bottom fallback:[%s^%s] -> [%s^(%s)]`, _k[0], _k[1], _k[0], strings.Join(fmailies, ","))
+ PrintLog(self.lcb, LogSWarning, `Font bottom fallback:[%s^%s] -> [%s^(%s)]`, _k[0], _k[1], _k[0], strings.Join(fmailies, ","))
} else {
- printLog(self.lcb, LogSWarning, `Font bottom fallback:[%s^%s] -> [%s^%s]`, _k[0], _k[1], _k[0], fmailies[0])
+ PrintLog(self.lcb, LogSWarning, `Font bottom fallback:[%s^%s] -> [%s^%s]`, _k[0], _k[1], _k[0], fmailies[0])
}
} else {
- printLog(self.lcb, LogSWarning, `Font bottom fallback:[%s^%s] -> [%s]`, _k[0], _k[1], _k[0])
+ PrintLog(self.lcb, LogSWarning, `Font bottom fallback:[%s^%s] -> [%s]`, _k[0], _k[1], _k[0])
}
return true
}
@@ -557,7 +557,7 @@ func (self *assProcessor) reMap() {
}
}
for _, v := range m {
- printLog(self.lcb, LogInfo, `Font selected:[%s] -> "%s"[%d]`, v.oldName, v.file, v.index)
+ PrintLog(self.lcb, LogInfo, `Font selected:[%s] -> "%s"[%d]`, v.oldName, v.file, v.index)
}
self.m = m
}
@@ -573,7 +573,7 @@ func (self *assProcessor) createFontSubset(font *fontInfo) bool {
e = ".ttf"
}
if os.MkdirAll(self.output, os.ModePerm) != nil {
- printLog(self.lcb, LogError, "Failed to create the output folder.")
+ PrintLog(self.lcb, LogError, "Failed to create the output folder.")
return false
}
str := string(font.runes)
@@ -597,13 +597,13 @@ func (self *assProcessor) createFontSubset(font *fontInfo) bool {
ok = err == nil && s.ExitCode() == 0
}
if !ok {
- printLog(self.lcb, LogError, `Failed to subset font: "%s"[%d].`, font.oldName, font.index)
+ PrintLog(self.lcb, LogError, `Failed to subset font: "%s"[%d].`, font.oldName, font.index)
} else {
font.sFont = _fn
}
} else {
- printLog(self.lcb, LogError, `Failed to write the font text: "%s".`, n)
+ PrintLog(self.lcb, LogError, `Failed to write the font text: "%s".`, n)
}
return ok
}
@@ -612,7 +612,7 @@ func (self *assProcessor) createFontsSubset() bool {
self.reMap()
err := os.RemoveAll(self.output)
if !(err == nil || err == os.ErrNotExist) {
- printLog(self.lcb, LogError, "Failed to clean the output folder.")
+ PrintLog(self.lcb, LogError, "Failed to clean the output folder.")
return false
}
ok := 0
@@ -691,11 +691,11 @@ func (self *assProcessor) changeFontName(font *fontInfo) bool {
ec++
_, n, _, _ := splitPath(font.sFont)
_ = os.Remove(font.sFont)
- printLog(self.lcb, LogError, `Failed to compile the font: "%s".`, n)
+ PrintLog(self.lcb, LogError, `Failed to compile the font: "%s".`, n)
}
}
} else {
- printLog(self.lcb, LogError, `Failed to change the font name: "%s".`, font.oldName)
+ PrintLog(self.lcb, LogError, `Failed to change the font name: "%s".`, font.oldName)
}
}
}
@@ -781,7 +781,7 @@ func (self *assProcessor) replaceFontNameInAss() bool {
}
if !ok {
ec++
- printLog(self.lcb, LogError, `Failed to write the new ass file: "%s".`, fn)
+ PrintLog(self.lcb, LogError, `Failed to write the new ass file: "%s".`, fn)
}
}
return ec == 0
@@ -829,7 +829,7 @@ func (self *assProcessor) createFontsCache(output string) []string {
if c != nil {
ok++
cache = append(cache, *c)
- printLog(self.lcb, LogProgress, "Cache font (%d/%d) done.", ok, l)
+ PrintLog(self.lcb, LogProgress, "Cache font (%d/%d) done.", ok, l)
} else {
el = append(el, _item)
}
@@ -856,7 +856,7 @@ func (self *assProcessor) createFontsCache(output string) []string {
d, _, _, _ := splitPath(output)
_ = os.MkdirAll(d, os.ModePerm)
if ioutil.WriteFile(output, data, os.ModePerm) != nil {
- printLog(self.lcb, LogError, `Failed to write cache file: "%s"`, output)
+ PrintLog(self.lcb, LogError, `Failed to write cache file: "%s"`, output)
}
}
return el
@@ -874,11 +874,11 @@ func (self *assProcessor) copyFontsFromCache() bool {
fn = path.Join(self.output, fn)
if copyFile(v.file, fn) == nil {
i++
- printLog(self.lcb, LogProgress, "Copy (%d/%d) done.", i, l)
+ PrintLog(self.lcb, LogProgress, "Copy (%d/%d) done.", i, l)
}
} else {
ec++
- printLog(self.lcb, LogError, `Missing the font: "%s".`, k)
+ PrintLog(self.lcb, LogError, `Missing the font: "%s".`, k)
}
}
}
diff --git a/mkvlib/ass2pgs.go b/mkvlib/ass2pgs.go
index 6eb6e6d..4f0d99a 100644
--- a/mkvlib/ass2pgs.go
+++ b/mkvlib/ass2pgs.go
@@ -22,7 +22,7 @@ func ass2Pgs(input []string, resolution, frameRate, fontsDir, output string, lcb
s, err := p.Wait()
r = err == nil && s.ExitCode() == 0
if !r {
- printLog(lcb, LogError, `Failed to Ass2Pgs:"%s"`, item)
+ PrintLog(lcb, LogError, `Failed to Ass2Pgs:"%s"`, item)
_ = os.Remove(fn)
}
}
diff --git a/mkvlib/go.mod b/mkvlib/go.mod
index 2898576..5f11b7d 100644
--- a/mkvlib/go.mod
+++ b/mkvlib/go.mod
@@ -5,6 +5,7 @@ go 1.18
require (
github.com/antchfx/xmlquery v1.3.10
github.com/asticode/go-astikit v0.29.1
+ github.com/fatih/color v1.13.0
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
golang.org/x/text v0.3.6
@@ -13,5 +14,8 @@ require (
require (
github.com/antchfx/xpath v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
+ github.com/mattn/go-colorable v0.1.9 // indirect
+ github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect
+ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
)
diff --git a/mkvlib/mkv.go b/mkvlib/mkv.go
index 320e9ec..80c5bf1 100644
--- a/mkvlib/mkv.go
+++ b/mkvlib/mkv.go
@@ -67,7 +67,7 @@ func (self *mkvProcessor) DumpMKV(file, output string, subset bool, lcb logCallb
ec := 0
obj := self.GetMKVInfo(file)
if obj == nil {
- printLog(lcb, LogError, `Failed to get the file info: "%s".`, file)
+ PrintLog(lcb, LogError, `Failed to get the file info: "%s".`, file)
return false
}
attachments := make([]string, 0)
@@ -124,7 +124,7 @@ func (self *mkvProcessor) DumpMKV(file, output string, subset bool, lcb logCallb
ec++
}
} else {
- printLog(lcb, LogInfo, `This file is not has the subtitles & attachments: "%s"`, file)
+ PrintLog(lcb, LogInfo, `This file is not has the subtitles & attachments: "%s"`, file)
}
return ec == 0
}
@@ -132,7 +132,7 @@ func (self *mkvProcessor) DumpMKV(file, output string, subset bool, lcb logCallb
func (self *mkvProcessor) CheckSubset(file string, lcb logCallback) (bool, bool) {
obj := self.GetMKVInfo(file)
if obj == nil {
- printLog(lcb, LogError, `Failed to get the file info: "%s".`, file)
+ PrintLog(lcb, LogError, `Failed to get the file info: "%s".`, file)
return false, true
}
ass := false
@@ -210,10 +210,10 @@ func (self *mkvProcessor) DumpMKVs(dir, output string, subset bool, lcb logCallb
p = path.Join(output, d, f)
if !self.DumpMKV(item, p, subset, lcb) {
ok = false
- printLog(lcb, LogError, `Failed to dump the file: "%s".`, item)
+ PrintLog(lcb, LogError, `Failed to dump the file: "%s".`, item)
} else {
_ok++
- printLog(lcb, LogProgress, "Dump (%d/%d) done.", _ok, l)
+ PrintLog(lcb, LogProgress, "Dump (%d/%d) done.", _ok, l)
}
}
return ok
@@ -226,11 +226,11 @@ func (self *mkvProcessor) QueryFolder(dir string, lcb logCallback) []string {
for i, file := range files {
a, b := self.CheckSubset(file, lcb)
if b {
- printLog(lcb, LogError, `Failed to check subset for file: "%s".`, file)
+ PrintLog(lcb, LogError, `Failed to check subset for file: "%s".`, file)
} else if !a {
lines = append(lines, file)
}
- printLog(lcb, LogProgress, "Query (%d/%d) done.", i+1, l)
+ PrintLog(lcb, LogProgress, "Query (%d/%d) done.", i+1, l)
}
return lines
}
@@ -258,9 +258,9 @@ func (self *mkvProcessor) CreateMKVs(vDir, sDir, fDir, tDir, oDir, slang, stitle
fn += ".mkv"
}
if _a, _ := isExists(fn); _a && self.noverwrite {
- printLog(lcb, LogInfo, `Existing file: "%s",skip.`, fn)
+ PrintLog(lcb, LogInfo, `Existing file: "%s",skip.`, fn)
_ok++
- printLog(lcb, LogProgress, "Create (%d/%d) done.", _ok, l)
+ PrintLog(lcb, LogProgress, "Create (%d/%d) done.", _ok, l)
continue
}
for _, sub := range tmp {
@@ -292,10 +292,10 @@ func (self *mkvProcessor) CreateMKVs(vDir, sDir, fDir, tDir, oDir, slang, stitle
}
if ec > 0 {
ok = false
- printLog(lcb, LogError, `Failed to create the file: "%s".`, item)
+ PrintLog(lcb, LogError, `Failed to create the file: "%s".`, item)
} else {
_ok++
- printLog(lcb, LogProgress, "Create (%d/%d) done.", _ok, l)
+ PrintLog(lcb, LogProgress, "Create (%d/%d) done.", _ok, l)
}
}
_ = os.RemoveAll(tDir)
@@ -317,9 +317,9 @@ func (self *mkvProcessor) MakeMKVs(dir, data, output, slang, stitle string, lcb
fn += ".mkv"
}
if _a, _ := isExists(fn); _a && self.noverwrite {
- printLog(lcb, LogInfo, `Existing file: "%s",skip.`, fn)
+ PrintLog(lcb, LogInfo, `Existing file: "%s",skip.`, fn)
_ok++
- printLog(lcb, LogProgress, "Make (%d/%d) done.", _ok, l)
+ PrintLog(lcb, LogProgress, "Make (%d/%d) done.", _ok, l)
continue
}
p = path.Join(data, d, f)
@@ -330,10 +330,10 @@ func (self *mkvProcessor) MakeMKVs(dir, data, output, slang, stitle string, lcb
tracks := append(subs, asses...)
if !self.CreateMKV(item, tracks, attachments, fn, slang, stitle, true) {
ok = false
- printLog(lcb, LogError, `Failed to make the file: "%s".`, item)
+ PrintLog(lcb, LogError, `Failed to make the file: "%s".`, item)
} else {
_ok++
- printLog(lcb, LogProgress, "Make (%d/%d) done.", _ok, l)
+ PrintLog(lcb, LogProgress, "Make (%d/%d) done.", _ok, l)
}
}
return ok
@@ -515,11 +515,11 @@ func (self *mkvProcessor) CreateTestVideo(asses []string, s, fontdir, enc string
ok := self.CreateBlankOrBurnVideo(0, s, enc, v, fontdir, _output)
if !ok {
ec++
- printLog(lcb, LogError, `Failed to create the test video file: "%s"`, _output)
+ PrintLog(lcb, LogError, `Failed to create the test video file: "%s"`, _output)
_ = os.Remove(_output)
} else {
_ok++
- printLog(lcb, LogProgress, "CT (%d/%d) done.", _ok, l)
+ PrintLog(lcb, LogProgress, "CT (%d/%d) done.", _ok, l)
}
}
return ec == 0
@@ -542,16 +542,16 @@ func (self *mkvProcessor) CreateTestVideo(asses []string, s, fontdir, enc string
s = path.Join(d, fmt.Sprintf("%s.mp4", n))
if !self.CreateBlankOrBurnVideo(t.Milliseconds(), "", enc, "", "", s) {
ok = false
- printLog(lcb, LogError, `Failed to create the temp video file: "%s".`, s)
+ PrintLog(lcb, LogError, `Failed to create the temp video file: "%s".`, s)
}
}
if ok {
output := path.Join(d, fmt.Sprintf("%s.mkv", n))
if !self.CreateMKV(s, asses, _fonts, output, "", "", true) {
ok = false
- printLog(lcb, LogError, `Failed to create the test video file: "%s".`, output)
+ PrintLog(lcb, LogError, `Failed to create the test video file: "%s".`, output)
} else {
- printLog(lcb, LogProgress, "CT done.")
+ PrintLog(lcb, LogProgress, "CT done.")
}
}
if _t {
diff --git a/mkvlib/shared.go b/mkvlib/shared.go
index 613f9a9..379c336 100644
--- a/mkvlib/shared.go
+++ b/mkvlib/shared.go
@@ -2,6 +2,7 @@ package mkvlib
import (
"fmt"
+ "github.com/fatih/color"
"log"
"os"
"os/exec"
@@ -11,7 +12,7 @@ import (
)
const libName = "mkvlib"
-const libVer = "v2.1.5"
+const libVer = "v2.1.6"
const LibFName = libName + " " + libVer
@@ -62,21 +63,21 @@ func (self *processorGetter) InitProcessorInstance(lcb logCallback) bool {
_, _ass2bdnxml := exec.LookPath(ass2bdnxml)
_, _ffmpeg := exec.LookPath(ffmpeg)
if _ttx != nil || _pyftsubset != nil {
- printLog(lcb, LogError, `Missing dependency: fonttools (need "%s" & "%s").`, ttx, pyftsubset)
+ PrintLog(lcb, LogError, `Missing dependency: fonttools (need "%s" & "%s").`, ttx, pyftsubset)
ec++
}
if _mkvextract != nil || _mkvmerge != nil {
- printLog(lcb, LogError, `Missing dependency: mkvtoolnix (need "%s" & "%s").`, mkvextract, mkvmerge)
+ PrintLog(lcb, LogError, `Missing dependency: mkvtoolnix (need "%s" & "%s").`, mkvextract, mkvmerge)
ec++
}
if _ass2bdnxml != nil {
- printLog(lcb, LogWarning, `Missing dependency: ass2bdnxml.`)
+ PrintLog(lcb, LogWarning, `Missing dependency: ass2bdnxml.`)
//ec++
}
if _ffmpeg != nil {
- printLog(lcb, LogWarning, `Missing dependency: ffmpeg.`)
+ PrintLog(lcb, LogWarning, `Missing dependency: ffmpeg.`)
//ec++
}
@@ -98,11 +99,29 @@ func (self *processorGetter) GetProcessorInstance() *mkvProcessor {
return nil
}
-func printLog(lcb logCallback, l byte, f string, v ...interface{}) {
+func PrintLog(lcb logCallback, l byte, f string, v ...interface{}) {
+ str := fmt.Sprintf(f, v...)
if lcb != nil {
- lcb(l, fmt.Sprintf(f, v...))
+ lcb(l, str)
} else {
- log.Printf(f, v...)
+ switch l {
+ case LogInfo:
+ str = color.BlueString(str)
+ break
+ case LogWarning:
+ str = color.YellowString(str)
+ break
+ case LogSWarning:
+ str = color.HiYellowString(str)
+ break
+ case LogError:
+ str = color.RedString(str)
+ break
+ case LogProgress:
+ str = color.GreenString(str)
+ break
+ }
+ log.Print(str)
}
}
diff --git a/mkvtool/main.go b/mkvtool/main.go
index 8507eac..839315d 100644
--- a/mkvtool/main.go
+++ b/mkvtool/main.go
@@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"github.com/MkvAutoSubset/MkvAutoSubset/mkvlib"
+ "github.com/fatih/color"
"io"
"io/ioutil"
"log"
@@ -16,7 +17,7 @@ import (
)
const appName = "MKV Tool"
-const appVer = "v4.1.5"
+const appVer = "v4.1.6"
const tTitle = appName + " " + appVer
var appFN = fmt.Sprintf("%s %s %s/%s", appName, appVer, runtime.GOOS, runtime.GOARCH)
@@ -115,22 +116,23 @@ func main() {
if flog != "" {
lf, err := os.Create(flog)
if err != nil {
- log.Printf(`Failed to create log file: "%s"`, flog)
+ mkvlib.PrintLog(nil, mkvlib.LogError, `Failed to create log file: "%s"`, flog)
}
mw := io.MultiWriter(os.Stdout, lf)
log.SetOutput(mw)
+ color.NoColor = true
}
ec := 0
defer func() {
if latestTag != "" && latestTag != appVer {
- log.Printf("New version available:%s", latestTag)
+ color.Green("New version available:%s", latestTag)
}
os.Exit(ec)
}()
if v {
- log.Printf("%s (powered by %s)", appFN, mkvlib.LibFName)
+ color.Green("%s (powered by %s)", appFN, mkvlib.LibFName)
return
}
getter := mkvlib.GetProcessorGetterInstance()
@@ -148,15 +150,15 @@ func main() {
if i != "" {
info := processer.GetFontInfo(i)
if info != nil {
- fmt.Printf("File: \t%s\n", info.File)
+ color.Blue("File: \t%s\n", info.File)
l := len(info.Fonts)
for _i := 0; _i < l; _i++ {
- fmt.Printf("\nIndex:\t%d\n", _i)
- fmt.Printf("\tNames:\t%s\n", strings.Join(info.Fonts[_i], "\n\t\t"))
- fmt.Printf("\tTypes:\t%s\n", strings.Join(info.Types[_i], "\n\t\t"))
+ color.Magenta("\nIndex:\t%d\n", _i)
+ color.Green("\tNames:\t%s\n", strings.Join(info.Fonts[_i], "\n\t\t"))
+ color.HiGreen("\tTypes:\t%s\n", strings.Join(info.Types[_i], "\n\t\t"))
}
} else {
- log.Printf("Failed to get font info: [%s]", i)
+ mkvlib.PrintLog(nil, mkvlib.LogError, "Failed to get font info: [%s]", i)
ec++
}
return
@@ -171,7 +173,7 @@ func main() {
el := len(list)
if el > 0 {
ec++
- log.Printf("Error list:(%d)\n%s", el, strings.Join(list, "\n"))
+ mkvlib.PrintLog(nil, mkvlib.LogInfo, "Error list:(%d)\n%s", el, strings.Join(list, "\n"))
}
return
}
@@ -187,14 +189,14 @@ func main() {
}
list := processer.GetFontsList(files, af, nil)
if len(list[0]) > 0 {
- fmt.Printf("Need list: \t%s\n", strings.Join(list[0], "\n\t\t"))
+ color.Yellow("Need list: \t%s\n", strings.Join(list[0], "\n\t\t"))
if len(list[1]) > 0 {
- fmt.Printf("\nMissing list: \t%s\n", strings.Join(list[1], "\n\t\t"))
+ color.HiYellow("\nMissing list: \t%s\n", strings.Join(list[1], "\n\t\t"))
} else if !nck {
- fmt.Println("\n*** All included fonts are found. ***")
+ color.Green("\n*** All included fonts are found. ***")
}
} else {
- fmt.Println("!!! No fonts found. !!!")
+ color.Yellow("!!! No fonts found. !!!")
}
if cfc {
if !processer.CopyFontsFromCache(files, co, nil) {
@@ -232,7 +234,7 @@ func main() {
if err {
ec++
} else {
- log.Printf("Need font subset: %v", !r)
+ mkvlib.PrintLog(nil, mkvlib.LogInfo, "Need font subset: %v", !r)
}
return
@@ -242,14 +244,14 @@ func main() {
if q {
lines := processer.QueryFolder(s, nil)
if len(lines) > 0 {
- log.Printf("Has item(s).")
+ mkvlib.PrintLog(nil, mkvlib.LogInfo, "Has item(s).")
data := []byte(strings.Join(lines, "\n"))
if os.WriteFile("list.txt", data, os.ModePerm) != nil {
- log.Printf("Failed to write the result file")
+ mkvlib.PrintLog(nil, mkvlib.LogError, "Failed to write the result file")
ec++
}
} else {
- log.Printf("No item.")
+ mkvlib.PrintLog(nil, mkvlib.LogInfo, "No item.")
}
return
}