shooter_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package shooter
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/allanpk716/ChineseSubFinder/pkg"
  6. "github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
  7. "github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
  8. "github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
  9. "github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
  10. "github.com/allanpk716/ChineseSubFinder/pkg/unit_test_helper"
  11. )
  12. func TestNewSupplier(t *testing.T) {
  13. pkg.ReadCustomAuthFile(log_helper.GetLogger4Tester())
  14. authKey := random_auth_key.AuthKey{
  15. BaseKey: pkg.BaseKey(),
  16. AESKey16: pkg.AESKey16(),
  17. AESIv16: pkg.AESIv16(),
  18. }
  19. //movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"
  20. //movie1 := "X:\\电影\\龙猫 (1988)\\龙猫 (1988) 1080p DTS.mkv"
  21. //movie1 := "X:\\电影\\消失爱人 (2016)\\消失爱人 (2016) 720p AAC.rmvb"
  22. //movie1 := "X:\\电影\\机动战士Z高达:星之继承者 (2005)\\机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
  23. //movie1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
  24. //movie1 := "X:\\电影\\An Invisible Sign (2010)\\An Invisible Sign (2010) 720p AAC.mp4"
  25. //movie1 := "X:\\连续剧\\少年间谍 (2020)\\Season 2\\Alex Rider - S02E01 - Episode One WEBDL-1080p.mkv"
  26. //movie1 := "X:\\连续剧\\黄石 (2018)\\Season 4\\Yellowstone (2018) - S04E05 - Under a Blanket of Red WEBDL-2160p.mkv"
  27. //movie1 := "X:\\连续剧\\瑞克和莫蒂 (2013)\\Season 5\\Rick and Morty - S05E09 - Forgetting Sarick Mortshall WEBRip-1080p.mkv"
  28. rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_spplier"}, 5, true)
  29. rootDir = filepath.Join(rootDir, "shooter")
  30. gVideoFPath, err := unit_test_helper.GenerateShooterVideoFile(rootDir)
  31. if err != nil {
  32. t.Fatal(err)
  33. }
  34. shooter := NewSupplier(file_downloader.NewFileDownloader(cache_center.NewCacheCenter("test", log_helper.GetLogger4Tester()), authKey))
  35. outList, err := shooter.getSubListFromFile(gVideoFPath)
  36. if err != nil {
  37. t.Error(err)
  38. }
  39. println(outList)
  40. for i, sublist := range outList {
  41. println(i, sublist.Name, sublist.Ext, sublist.Language.String(), sublist.Score, sublist.FileUrl, len(sublist.Data))
  42. }
  43. alive, _ := shooter.CheckAlive()
  44. if alive == false {
  45. t.Fatal("CheckAlive == false")
  46. }
  47. }