Просмотр исходного кода

添加多种字幕输出命名格式的 Interface

allan716 4 лет назад
Родитель
Сommit
1337aac229
2 измененных файлов с 14 добавлено и 4 удалено
  1. 9 0
      internal/ifaces/iSubFormatter.go
  2. 5 4
      internal/pkg/sub_helper/sub_helper.go

+ 9 - 0
internal/ifaces/iSubFormatter.go

@@ -0,0 +1,9 @@
+package ifaces
+
+import "github.com/allanpk716/ChineseSubFinder/internal/types"
+
+type ISubFormatter interface {
+	IsMatchThisFormat(subName string) bool
+
+	GenerateMixSubName(videoFileName, subExt string, subLang types.Language, extraSubPreName string) (string, string, string)
+}

+ 5 - 4
internal/pkg/sub_helper/sub_helper.go

@@ -370,20 +370,21 @@ func IsOldVersionSubPrefixName(subFileName string) (bool, string, string) {
 }
 
 // GenerateMixSubName 这里会生成类似的文件名 xxxx.chinese(中英,shooter)
-func GenerateMixSubName(videoFileName, subExt string, subLan types.Language, extraSubPreName string) (string, string, string) {
+func GenerateMixSubName(videoFileName, subExt string, subLang types.Language, extraSubPreName string) (string, string, string) {
 
 	videoFileNameWithOutExt := strings.ReplaceAll(filepath.Base(videoFileName),
 		filepath.Ext(videoFileName), "")
 	note := ""
+	// extraSubPreName 那个字幕网站下载的
 	if extraSubPreName != "" {
 		note = "," + extraSubPreName
 	}
 	defaultString := ".default"
 	forcedString := ".forced"
 
-	subNewName := videoFileNameWithOutExt + ".chinese" + "(" + language.Lang2ChineseString(subLan) + note + ")" + subExt
-	subNewNameWithDefault := videoFileNameWithOutExt + ".chinese" + "(" + language.Lang2ChineseString(subLan) + note + ")" + defaultString + subExt
-	subNewNameWithForced := videoFileNameWithOutExt + ".chinese" + "(" + language.Lang2ChineseString(subLan) + note + ")" + forcedString + subExt
+	subNewName := videoFileNameWithOutExt + ".chinese" + "(" + language.Lang2ChineseString(subLang) + note + ")" + subExt
+	subNewNameWithDefault := videoFileNameWithOutExt + ".chinese" + "(" + language.Lang2ChineseString(subLang) + note + ")" + defaultString + subExt
+	subNewNameWithForced := videoFileNameWithOutExt + ".chinese" + "(" + language.Lang2ChineseString(subLang) + note + ")" + forcedString + subExt
 
 	return subNewName, subNewNameWithDefault, subNewNameWithForced
 }