embyhelper_test.go 3.4 KB

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