subhd_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package subhd
  2. import (
  3. "fmt"
  4. "github.com/allanpk716/ChineseSubFinder/internal/logic/file_downloader"
  5. "github.com/allanpk716/ChineseSubFinder/internal/logic/series_helper"
  6. "github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
  7. "github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
  8. "github.com/allanpk716/ChineseSubFinder/internal/pkg/something_static"
  9. "github.com/allanpk716/ChineseSubFinder/internal/pkg/unit_test_helper"
  10. commonValue "github.com/allanpk716/ChineseSubFinder/internal/types/common"
  11. "path/filepath"
  12. "testing"
  13. "time"
  14. )
  15. // 无需关注这个测试用例,这个方案暂时弃用
  16. func TestSupplier_GetSubListFromFile(t *testing.T) {
  17. //movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"
  18. //movie1 := "X:\\电影\\Luca (2021)\\Luca (2021) WEBDL-1080p.mkv"
  19. //movie1 := "X:\\电影\\The Boss Baby Family Business (2021)\\The Boss Baby Family Business (2021) WEBDL-1080p.mkv"
  20. //movie1 := "X:\\电影\\Oslo (2021)\\Oslo (2021) WEBDL-1080p.mkv"
  21. //movie1 := "X:\\电影\\Spiral From the Book of Saw (2021)\\Spiral From the Book of Saw (2021) WEBDL-1080p.mkv"
  22. //movie1 := "X:\\电影\\消失爱人 (2016)\\消失爱人 (2016) 720p AAC.rmvb"
  23. //movie1 := "X:\\电影\\机动战士Z高达:星之继承者 (2005)\\机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
  24. getCode()
  25. rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_spplier"}, 5, true)
  26. movie1 := filepath.Join(rootDir, "zimuku", "movies", "消失爱人 (2016)", "消失爱人 (2016) 720p AAC.rmvb")
  27. subhd := NewSupplier(file_downloader.NewFileDownloader(settings.NewSettings(), log_helper.GetLogger4Tester()))
  28. outList, err := subhd.getSubListFromFile4Movie(movie1)
  29. if err != nil {
  30. t.Error(err)
  31. }
  32. println(outList)
  33. if len(outList) == 0 {
  34. println("now sub found")
  35. }
  36. for i, sublist := range outList {
  37. println(i, sublist.Name, sublist.Ext, sublist.Language.String(), sublist.Score, sublist.FileUrl, len(sublist.Data))
  38. }
  39. alive, _ := subhd.CheckAlive()
  40. if alive == false {
  41. t.Fatal("CheckAlive == false")
  42. }
  43. }
  44. // 无需关注这个测试用例,这个方案暂时弃用
  45. func TestSupplier_GetSubListFromFile4Series(t *testing.T) {
  46. //ser := "X:\\连续剧\\The Bad Batch" // tt12708542
  47. //ser := "X:\\连续剧\\瑞克和莫蒂 (2013)" //
  48. //ser := "X:\\连续剧\\杀死伊芙 (2018)" // tt7016936
  49. //ser := "X:\\连续剧\\Money.Heist"
  50. //ser := "X:\\连续剧\\黑钱胜地 (2017)"
  51. getCode()
  52. rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_spplier"}, 5, true)
  53. ser := filepath.Join(rootDir, "zimuku", "series", "黄石 (2018)")
  54. // 读取本地的视频和字幕信息
  55. seriesInfo, err := series_helper.ReadSeriesInfoFromDir(ser, 90, false)
  56. if err != nil {
  57. t.Fatal(err)
  58. }
  59. s := NewSupplier(file_downloader.NewFileDownloader(settings.NewSettings(), log_helper.GetLogger4Tester()))
  60. outList, err := s.GetSubListFromFile4Series(seriesInfo)
  61. if err != nil {
  62. t.Fatal(err)
  63. }
  64. println(outList)
  65. for i, sublist := range outList {
  66. println(i, sublist.Name, sublist.Ext, sublist.Language.String(), sublist.Score, len(sublist.Data))
  67. }
  68. }
  69. // 无需关注这个测试用例,这个方案暂时弃用
  70. func TestSupplier_getSubListFromKeyword4Movie(t *testing.T) {
  71. //imdbID := "tt12708542" // 星球大战:残次品
  72. //imdbID := "tt7016936" // 杀死伊芙
  73. imdbID := "tt2990738" // 恐怖直播
  74. //imdbID := "tt3032476" // 风骚律师
  75. //imdbID := "tt6468322" // 纸钞屋
  76. //imdbID := "tt15299712" // 云南虫谷
  77. //imdbID := "tt3626476" // Vacation Friends (2021)
  78. getCode()
  79. subhd := NewSupplier(file_downloader.NewFileDownloader(settings.NewSettings(), log_helper.GetLogger4Tester()))
  80. subInfos, err := subhd.getSubListFromKeyword4Movie(imdbID)
  81. if err != nil {
  82. t.Fatal(err)
  83. }
  84. for i, sublist := range subInfos {
  85. println(i, sublist.Name, sublist.Ext, sublist.Language.String(), sublist.Score, len(sublist.Data))
  86. }
  87. }
  88. func getCode() {
  89. nowTT := time.Now()
  90. nowTimeFileNamePrix := fmt.Sprintf("%d%d%d", nowTT.Year(), nowTT.Month(), nowTT.Day())
  91. updateTimeString, code, err := something_static.GetCodeFromWeb(log_helper.GetLogger4Tester(), nowTimeFileNamePrix)
  92. if err != nil {
  93. commonValue.SubhdCode = ""
  94. } else {
  95. commonValue.SubhdCode = code
  96. }
  97. fmt.Println("UpdateTime", updateTimeString)
  98. }