Browse Source

发现内置字幕可能有问题,需要加额外的识别逻辑,判断内置的字幕是否符合要求,不行就要找下一个内置的英文字幕。

Signed-off-by: 716 <[email protected]>
716 4 years ago
parent
commit
08f839cb44

+ 5 - 0
internal/logic/emby_helper/embyhelper.go

@@ -303,6 +303,11 @@ func (em *EmbyHelper) GetInternalEngSubAndExChineseEnglishSub(videoId string) (b
 	videoFileNameWithOutExt := strings.ReplaceAll(videoFileName, path.Ext(videoFileName), "")
 	// TODO 后续会新增一个功能,从视频中提取音频文件,然后识别转为字符,再进行与字幕的匹配
 	// 获取是否有内置的英文字幕,如果没有则无需继续往下
+	/*
+		这里有个梗,读取到的英文内置字幕很可能是残缺的,比如,基地 S01E04 Eng 第一个 Default Forced Sub,就不对,内容的 Dialogue 很少。
+		然后第二个 Eng 字幕才对。那么考虑到兼容性, 可能后续有短视频,也就不能简单的按 Dialogue 的多少去衡量。大概会做一个功能。
+		读取到视频的总长度,然后再分析 Dialogue 的时间出现的部分与整体时间轴的占比,又或者是 Dialogue 之间的连续成都分析,这个有待测试。
+	*/
 	haveInsideEngSub := false
 	InsideEngSubIndex := 0
 	for _, stream := range videoInfo.MediaStreams {

+ 2 - 1
internal/logic/sub_timeline_fixer/sub_timeline_fixer_helper_test.go

@@ -18,11 +18,12 @@ func TestSubTimelineFixerHelper_fixOneVideoSub(t *testing.T) {
 	// What If  - S01E09    171499
 	// Dan Brown's The Lost Symbol - S01E01    172412
 	// 基地 S01E03 166840
+	// 基地 S01E04 173354
 	// 81873 -- R&M - S05E01
 	// 145499 -- R&M - S05E10
 	config := pkg.GetConfig()
 	fixer := NewSubTimelineFixerHelper(config.EmbyConfig)
-	err := fixer.fixOneVideoSub("145499", "")
+	err := fixer.fixOneVideoSub("173354", "")
 	if err != nil {
 		t.Fatal(err)
 	}

+ 18 - 16
internal/pkg/emby_api/emby_api_test.go

@@ -32,21 +32,6 @@ func TestEmbyHelper_GetItemsAncestors(t *testing.T) {
 	println(items[0].Name, items[0].Path)
 }
 
-func TestEmbyHelper_GetItemVideoInfo(t *testing.T) {
-	em := NewEmbyApi(pkg.GetConfig().EmbyConfig)
-	// 95813 -- 命运夜
-	// 96564 -- The Bad Batch - S01E11
-	// R&M S05E10  2 org english, 5 简英 145499
-	// 基地 S01E03 166840
-	// 算牌人 166837
-	videoInfo, err := em.GetItemVideoInfo("172412")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	println(videoInfo.Name, videoInfo.Path)
-}
-
 func TestEmbyHelper_GetItemVideoInfoByUserId(t *testing.T) {
 	em := NewEmbyApi(pkg.GetConfig().EmbyConfig)
 	// 95813 -- 命运夜
@@ -85,12 +70,29 @@ func TestEmbyHelper_GetUserIdList(t *testing.T) {
 	}
 }
 
+func TestEmbyHelper_GetItemVideoInfo(t *testing.T) {
+	em := NewEmbyApi(pkg.GetConfig().EmbyConfig)
+	// 95813 -- 命运夜
+	// 96564 -- The Bad Batch - S01E11
+	// R&M S05E10  2 org english, 5 简英 145499
+	// 基地 S01E03 166840
+	// 基地 S01E04 173354
+	// 算牌人 166837
+	videoInfo, err := em.GetItemVideoInfo("173354")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	println(videoInfo.Name, videoInfo.Path, videoInfo.MediaSources[0].Id)
+}
+
 func TestEmbyApi_GetSubFileData(t *testing.T) {
 	em := NewEmbyApi(pkg.GetConfig().EmbyConfig)
 	// R&M S05E10  2 org english, 5 简英					"145499", "c4678509adb72a8b5034bdac2f1fccde", "5", ".ass"
 	// 基地 S01E03		2=eng 	6=chi 	45=简英			"166840", "d6c68ec6097aeceb9f5c1d82add66213", "2", ".ass"
+	// 基地 S01E04		2=eng 	6=chi 	45=简英			"173354", "c08f514cc1708f3fadea56e489da33db", "2", ".ass"
 
-	subFileData, err := em.GetSubFileData("145499", "c4678509adb72a8b5034bdac2f1fccde", "4", ".ass")
+	subFileData, err := em.GetSubFileData("173354", "c08f514cc1708f3fadea56e489da33db", "3", ".ass")
 	//subFileData, err := em.GetSubFileData("145499", "c4678509adb72a8b5034bdac2f1fccde", "5", ".ass")
 	//subFileData, err := em.GetSubFileData("166840", "d6c68ec6097aeceb9f5c1d82add66213", "45", ".ass")
 	if err != nil {