test_statistics_subs_score_test.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package TestCode
  2. import (
  3. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/log_helper"
  4. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/logic/sub_timeline_fixer"
  5. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/settings"
  6. "path/filepath"
  7. "testing"
  8. )
  9. func Test_statistics_subs_score(t *testing.T) {
  10. type args struct {
  11. baseAudioFileFPath string
  12. baseSubFileFPath string
  13. subSearchRootPath string
  14. }
  15. tests := []struct {
  16. name string
  17. args args
  18. }{
  19. {
  20. name: "Test_statistics_subs_score",
  21. args: args{
  22. baseAudioFileFPath: "C:\\temp\\video\\base\\RM-S05E01\\未知语言_1.pcm",
  23. baseSubFileFPath: "C:\\temp\\video\\base\\RM-S05E01\\英_2.srt",
  24. subSearchRootPath: "X:\\电影",
  25. },
  26. },
  27. }
  28. for _, tt := range tests {
  29. t.Run(tt.name, func(t *testing.T) {
  30. statistics_subs_score(tt.args.baseAudioFileFPath, tt.args.baseSubFileFPath, tt.args.subSearchRootPath)
  31. })
  32. }
  33. }
  34. func Test_statistics_subs_score_one(t *testing.T) {
  35. type args struct {
  36. baseAudioFileFPath string
  37. baseSubFileFPath string
  38. srcSubFileFPath string
  39. }
  40. tests := []struct {
  41. name string
  42. args args
  43. }{
  44. {
  45. name: "Test_statistics_subs_score_one",
  46. args: args{
  47. baseAudioFileFPath: "C:\\temp\\video\\base\\RM-S05E01\\未知语言_1.pcm",
  48. baseSubFileFPath: "C:\\temp\\video\\base\\RM-S05E01\\英_2.srt",
  49. srcSubFileFPath: "C:\\temp\\video\\Rick and Morty - S05E01 - Mort Dinner Rick Andre WEBDL-1080p.chinese(简英,fix).srt",
  50. },
  51. },
  52. {
  53. name: "Test_statistics_subs_score_one2",
  54. args: args{
  55. baseAudioFileFPath: "C:\\temp\\video\\base\\RM-S05E01\\未知语言_1.pcm",
  56. baseSubFileFPath: "C:\\temp\\video\\base\\RM-S05E01\\英_2.srt",
  57. srcSubFileFPath: "C:\\temp\\video\\The Boys - S03E01 - Payback WEBRip-1080p.chinese(简英,subhd).ass",
  58. },
  59. },
  60. }
  61. for _, tt := range tests {
  62. t.Run(tt.name, func(t *testing.T) {
  63. statistics_subs_score_one(tt.args.baseAudioFileFPath, tt.args.baseSubFileFPath, tt.args.srcSubFileFPath)
  64. })
  65. }
  66. }
  67. func Test_statistics_subs_score_is_match(t *testing.T) {
  68. type args struct {
  69. videoFPath string
  70. subSearchRootPath string
  71. }
  72. tests := []struct {
  73. name string
  74. args args
  75. }{
  76. {
  77. name: "Test_statistics_subs_score_is_match",
  78. args: args{
  79. videoFPath: "C:\\temp\\video\\Rick and Morty - S05E01 - Mort Dinner Rick Andre WEBDL-1080p.mkv",
  80. subSearchRootPath: "X:\\连续剧\\瑞克和莫蒂 (2013)",
  81. },
  82. },
  83. }
  84. for _, tt := range tests {
  85. t.Run(tt.name, func(t *testing.T) {
  86. logger := log_helper.GetLogger4Tester()
  87. s := sub_timeline_fixer.NewSubTimelineFixerHelperEx(logger, *settings.NewTimelineFixerSettings())
  88. bok, ffmpegInfo, audioVADInfos, infoBase, err := s.IsVideoCanExportSubtitleAndAudio(tt.args.videoFPath)
  89. if err != nil {
  90. logger.Errorln("IsVideoCanExportSubtitleAndAudio", err)
  91. return
  92. }
  93. if bok == false {
  94. logger.Errorln("IsVideoCanExportSubtitleAndAudio", "bok == false")
  95. return
  96. }
  97. statistics_subs_score_is_match(logger, s, ffmpegInfo, audioVADInfos, infoBase, tt.args.subSearchRootPath, filepath.Base(tt.args.videoFPath))
  98. })
  99. }
  100. }