xunlei_test.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package xunlei
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/allanpk716/ChineseSubFinder/pkg"
  6. "github.com/allanpk716/ChineseSubFinder/pkg/logic/file_downloader"
  7. "github.com/allanpk716/ChineseSubFinder/pkg/cache_center"
  8. "github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
  9. "github.com/allanpk716/ChineseSubFinder/pkg/my_util"
  10. "github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
  11. "github.com/allanpk716/ChineseSubFinder/pkg/settings"
  12. "github.com/allanpk716/ChineseSubFinder/pkg/unit_test_helper"
  13. )
  14. func TestGetList(t *testing.T) {
  15. //movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"
  16. //movie1 := "X:\\电影\\龙猫 (1988)\\龙猫 (1988) 1080p DTS.mkv"
  17. //movie1 := "X:\\电影\\消失爱人 (2016)\\消失爱人 (2016) 720p AAC.rmvb"
  18. //movie1 := "X:\\电影\\Spiral From the Book of Saw (2021)\\Spiral From the Book of Saw (2021) WEBDL-1080p.mkv"
  19. //movie1 := "X:\\电影\\机动战士Z高达:星之继承者 (2005)\\机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
  20. //movie1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
  21. //movie1 := "X:\\连续剧\\黄石 (2018)\\Season 4\\Yellowstone (2018) - S04E05 - Under a Blanket of Red WEBDL-2160p.mkv"
  22. //movie1 := "X:\\动漫\\碧蓝之海 (2018)\\Season 1\\碧蓝之海 - S01E01 - [UHA-WINGS][Grand Blue][01][BDRIP 1920x1080 x264 FLACx2].mkv"
  23. //movie1 := "X:\\连续剧\\瑞克和莫蒂 (2013)\\Season 5\\Rick and Morty - S05E01 - Mort Dinner Rick Andre WEBDL-1080p.mkv"
  24. //movie1 := "X:\\电影\\手机 (2003)\\手机 (2003) 720p Cooker.rmvb"
  25. rootDir := unit_test_helper.GetTestDataResourceRootPath([]string{"sub_spplier"}, 5, true)
  26. rootDir = filepath.Join(rootDir, "xunlei")
  27. gVideoFPath, err := unit_test_helper.GenerateXunleiVideoFile(rootDir)
  28. if err != nil {
  29. t.Fatal(err)
  30. }
  31. defInstance()
  32. outList, err := xunleiInstance.getSubListFromFile(gVideoFPath)
  33. if err != nil {
  34. t.Error(err)
  35. }
  36. println(outList)
  37. for i, sublist := range outList {
  38. println(i, sublist.Name, sublist.Ext, sublist.Language.String(), sublist.Score, len(sublist.Data))
  39. }
  40. alive, _ := xunleiInstance.CheckAlive()
  41. if alive == false {
  42. t.Fatal("CheckAlive == false")
  43. }
  44. }
  45. var xunleiInstance *Supplier
  46. func defInstance() {
  47. my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
  48. authKey := random_auth_key.AuthKey{
  49. BaseKey: pkg.BaseKey(),
  50. AESKey16: pkg.AESKey16(),
  51. AESIv16: pkg.AESIv16(),
  52. }
  53. xunleiInstance = NewSupplier(file_downloader.NewFileDownloader(
  54. cache_center.NewCacheCenter("test", settings.GetSettings(), log_helper.GetLogger4Tester()), authKey))
  55. }