embyhelper_test.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package emby_helper
  2. import (
  3. "testing"
  4. "github.com/ChineseSubFinder/ChineseSubFinder/pkg"
  5. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/media_info_dealers"
  6. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/random_auth_key"
  7. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/subtitle_best_api"
  8. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/log_helper"
  9. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/settings"
  10. )
  11. // TODO 暂不方便在其他环境进行单元测试
  12. func TestEmbyHelper_GetRecentlyAddVideoList(t *testing.T) {
  13. //defInstance()
  14. //
  15. //em := NewEmbyHelper(dealers)
  16. //movieList, seriesList, err := em.GetRecentlyAddVideoList(&ec, false, 1000000)
  17. //if err != nil {
  18. // t.Fatal(err)
  19. //}
  20. //println(len(movieList), len(seriesList))
  21. }
  22. // TODO 暂不方便在其他环境进行单元测试
  23. func TestEmbyHelper_RefreshEmbySubList(t *testing.T) {
  24. //config := config.GetConfig()
  25. //em := NewEmbyHelper(config.EmbyConfig)
  26. //bok, err := em.refreshEmbySubList()
  27. //if err != nil {
  28. // t.Fatal(err)
  29. //}
  30. //println(bok)
  31. }
  32. // TODO 暂不方便在其他环境进行单元测试
  33. func TestEmbyHelper_GetInternalEngSubAndExSub(t *testing.T) {
  34. //config := config.GetConfig()
  35. //em := NewEmbyHelper(config.EmbyConfig)
  36. //// 81873 -- R&M - S05E01
  37. //// R&M S05E10 2 org english, 5 简英 145499
  38. //// 基地 S01E03 166840
  39. //found, internalEngSub, exCh_EngSub, err := em.GetInternalEngSubAndExChineseEnglishSub("166840")
  40. //if err != nil {
  41. // t.Fatal(err)
  42. //}
  43. //if found == false {
  44. // t.Fatal("need found sub")
  45. //}
  46. //
  47. //println(internalEngSub[0].FileName, exCh_EngSub[0].FileName)
  48. }
  49. // TODO 暂不方便在其他环境进行单元测试
  50. func TestEmbyHelper_GetPlayedItemsSubtitle(t *testing.T) {
  51. //em := NewEmbyHelper(ec)
  52. //moviePhyFPathMap, seriesPhyFPathMap, err := em.GetPlayedItemsSubtitle()
  53. //if err != nil {
  54. // t.Fatal(err)
  55. //}
  56. //
  57. //for videoPhyPath, subPhyPath := range moviePhyFPathMap {
  58. // println(videoPhyPath, "--", subPhyPath)
  59. // if my_util.IsFile(videoPhyPath) == false {
  60. // t.Fatal("not found,", videoPhyPath)
  61. // }
  62. // if my_util.IsFile(subPhyPath) == false {
  63. // t.Fatal("not found,", subPhyPath)
  64. // }
  65. //}
  66. //
  67. //for videoPhyPath, subPhyPath := range seriesPhyFPathMap {
  68. // println(videoPhyPath, "--", subPhyPath)
  69. // if my_util.IsFile(videoPhyPath) == false {
  70. // t.Fatal("not found,", videoPhyPath)
  71. // }
  72. // if my_util.IsFile(subPhyPath) == false {
  73. // t.Fatal("not found,", subPhyPath)
  74. // }
  75. //}
  76. }
  77. func TestEmbyHelper_IsVideoPlayed(t *testing.T) {
  78. ////// 95813 -- 命运夜
  79. ////// 96564 -- The Bad Batch - S01E11
  80. ////// 108766 -- R&M - S05E06
  81. ////// 145499 -- R&M - S05E10
  82. //tmpSettings := settings.NewSettings()
  83. //tmpSettings.EmbySettings = &ec
  84. //em := NewEmbyHelper(log_helper.GetLogger4Tester(), tmpSettings)
  85. //played, err := em.IsVideoPlayed("145499")
  86. //if err != nil {
  87. // t.Fatal(err)
  88. //}
  89. //
  90. //if played == false {
  91. // t.Fatal("need played")
  92. //}
  93. }
  94. func defInstance() {
  95. settings.SetConfigRootPath(pkg.ConfigRootDirFPath())
  96. pkg.ReadCustomAuthFile(log_helper.GetLogger4Tester())
  97. authKey := random_auth_key.AuthKey{
  98. BaseKey: pkg.BaseKey(),
  99. AESKey16: pkg.AESKey16(),
  100. AESIv16: pkg.AESIv16(),
  101. }
  102. nowSettings := settings.Get()
  103. nowSettings.ExperimentalFunction.ShareSubSettings.ShareSubEnabled = true
  104. dealers = media_info_dealers.NewDealers(log_helper.GetLogger4Tester(),
  105. subtitle_best_api.NewSubtitleBestApi(log_helper.GetLogger4Tester(), authKey))
  106. }
  107. var (
  108. dealers *media_info_dealers.Dealers
  109. )
  110. var ec = settings.EmbySettings{
  111. AddressUrl: "http://192.168.50.252:8096",
  112. APIKey: "xxxxxxx",
  113. MaxRequestVideoNumber: 100,
  114. MoviePathsMapping: map[string]string{
  115. "X:\\电影": "/mnt/share1/电影",
  116. },
  117. SeriesPathsMapping: map[string]string{
  118. "X:\\连续剧": "/mnt/share1/连续剧",
  119. },
  120. AutoOrManual: true,
  121. Threads: 1,
  122. }