embyhelper_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package emby_helper
  2. import (
  3. embyHelper "github.com/allanpk716/ChineseSubFinder/internal/pkg/emby_api"
  4. "github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
  5. "github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
  6. "github.com/sirupsen/logrus"
  7. "sync"
  8. "testing"
  9. "time"
  10. )
  11. var ec = settings.EmbySettings{
  12. AddressUrl: "http://192.168.50.252:xxx",
  13. APIKey: "xxx",
  14. MaxRequestVideoNumber: 100,
  15. MoviePathsMapping: map[string]string{
  16. "X:\\电影": "/mnt/share1/电影",
  17. },
  18. SeriesPathsMapping: map[string]string{
  19. "X:\\连续剧": "/mnt/share1/连续剧",
  20. },
  21. }
  22. // TODO 暂不方便在其他环境进行单元测试
  23. func TestEmbyHelper_GetRecentlyAddVideoList(t *testing.T) {
  24. //embyConfig := settings.NewEmbySettings()
  25. //embyConfig.Enable = true
  26. //embyConfig.AddressUrl = "http://192.168.50.252:8096"
  27. //embyConfig.APIKey = "1"
  28. //embyConfig.SkipWatched = false
  29. //embyConfig.MaxRequestVideoNumber = 1000
  30. //embyConfig.MoviePathsMapping["X:\\电影"] = "/mnt/share1/电影"
  31. //embyConfig.MoviePathsMapping["X:\\连续剧"] = "/mnt/share1/连续剧"
  32. //
  33. //em := NewEmbyHelper(*embyConfig)
  34. //movieList, seriesList, err := em.GetRecentlyAddVideoListWithNoChineseSubtitle()
  35. //if err != nil {
  36. // t.Fatal(err)
  37. //}
  38. //println(len(movieList), len(seriesList))
  39. }
  40. // TODO 暂不方便在其他环境进行单元测试
  41. func TestEmbyHelper_RefreshEmbySubList(t *testing.T) {
  42. //config := config.GetConfig()
  43. //em := NewEmbyHelper(config.EmbyConfig)
  44. //bok, err := em.refreshEmbySubList()
  45. //if err != nil {
  46. // t.Fatal(err)
  47. //}
  48. //println(bok)
  49. }
  50. // TODO 暂不方便在其他环境进行单元测试
  51. func TestEmbyHelper_GetInternalEngSubAndExSub(t *testing.T) {
  52. //config := config.GetConfig()
  53. //em := NewEmbyHelper(config.EmbyConfig)
  54. //// 81873 -- R&M - S05E01
  55. //// R&M S05E10 2 org english, 5 简英 145499
  56. //// 基地 S01E03 166840
  57. //found, internalEngSub, exCh_EngSub, err := em.GetInternalEngSubAndExChineseEnglishSub("166840")
  58. //if err != nil {
  59. // t.Fatal(err)
  60. //}
  61. //if found == false {
  62. // t.Fatal("need found sub")
  63. //}
  64. //
  65. //println(internalEngSub[0].FileName, exCh_EngSub[0].FileName)
  66. }
  67. // TODO 暂不方便在其他环境进行单元测试
  68. func TestEmbyHelper_GetPlayedItemsSubtitle(t *testing.T) {
  69. //em := NewEmbyHelper(ec)
  70. //moviePhyFPathMap, seriesPhyFPathMap, err := em.GetPlayedItemsSubtitle()
  71. //if err != nil {
  72. // t.Fatal(err)
  73. //}
  74. //
  75. //for videoPhyPath, subPhyPath := range moviePhyFPathMap {
  76. // println(videoPhyPath, "--", subPhyPath)
  77. // if my_util.IsFile(videoPhyPath) == false {
  78. // t.Fatal("not found,", videoPhyPath)
  79. // }
  80. // if my_util.IsFile(subPhyPath) == false {
  81. // t.Fatal("not found,", subPhyPath)
  82. // }
  83. //}
  84. //
  85. //for videoPhyPath, subPhyPath := range seriesPhyFPathMap {
  86. // println(videoPhyPath, "--", subPhyPath)
  87. // if my_util.IsFile(videoPhyPath) == false {
  88. // t.Fatal("not found,", videoPhyPath)
  89. // }
  90. // if my_util.IsFile(subPhyPath) == false {
  91. // t.Fatal("not found,", subPhyPath)
  92. // }
  93. //}
  94. }
  95. func TestEmbyHelper_GetRecentlyAddVideoList1(t *testing.T) {
  96. }
  97. func TestEmbyHelper_IsVideoPlayed(t *testing.T) {
  98. em := NewEmbyHelper(log_helper.GetLogger4Tester(), *ec)
  99. moviePhyFPathMap, seriesPhyFPathMap, err := em.GetPlayedItemsSubtitle()
  100. if err != nil {
  101. t.Fatal(err)
  102. }
  103. played, err := ec.IsVideoPlayed(tt.args.videoID)
  104. }