Browse Source

跳过带有 -fix 标记的字幕,无需再次时间轴修正

Signed-off-by: allan716 <[email protected]>
allan716 4 years ago
parent
commit
6a9f795b61

+ 5 - 2
internal/logic/sub_timeline_fixer/sub_timeline_fixer_helper.go

@@ -108,7 +108,10 @@ func (s SubTimelineFixerHelper) fixOneVideoSub(videoId string, videoRootPath str
 		if exSubInfo.Ext == common.SubExtSRT {
 			inSelectSubIndex = 0
 		}
-
+		// 修正过的字幕有标记,将不会再次修复
+		if strings.Contains(exSubInfo.FileName, sub_timeline_fixer.FixMask) == true {
+			continue
+		}
 		bFound, subFixInfos, err := s.fixSubTimeline(internalEngSub[inSelectSubIndex], exSubInfo)
 		if err != nil {
 			return err
@@ -221,7 +224,7 @@ func (s SubTimelineFixerHelper) fixSubTimeline(enSubFile emby.SubInfo, ch_enSubF
 			hasDefault = true
 		}
 		// 生成对应字幕命名格式的,字幕命名。这里注意,normal 的时候, extraSubName+"-fix" 是无效的,不会被设置,也就是直接覆盖之前的字幕了。
-		subNewName, subNewNameDefault, _ := formatter.GenerateMixSubNameBase(fileNameWithOutExt, subExt, subLang, extraSubName+"-fix")
+		subNewName, subNewNameDefault, _ := formatter.GenerateMixSubNameBase(fileNameWithOutExt, subExt, subLang, extraSubName+sub_timeline_fixer.FixMask)
 
 		desFixSubFileFullPath := ""
 		if hasDefault == true {

+ 2 - 0
internal/pkg/sub_timeline_fixer/fixer.go

@@ -364,3 +364,5 @@ func (s *SubTimelineFixer) FixSubTimeline(infoSrc *subparser.FileInfo, inOffsetT
 
 const timeFormatAss = "15:04:05.00"
 const timeFormatSrt = "15:04:05,000"
+
+const FixMask = "-fix"

+ 1 - 1
internal/pkg/sub_timeline_fixer/fixer_test.go

@@ -324,7 +324,7 @@ func TestGetOffsetTime(t *testing.T) {
 			//}
 
 			if bok == true && got != 0 {
-				_, err = s.FixSubTimeline(infoSrc, got, tt.args.ch_enSubFile+"-fix"+infoBase.Ext)
+				_, err = s.FixSubTimeline(infoSrc, got, tt.args.ch_enSubFile+FixMask+infoBase.Ext)
 				if err != nil {
 					t.Fatal(err)
 				}