embyhelper_test.go 3.2 KB

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