Format3DTests.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Emby.Naming.Common;
  2. using Emby.Naming.Video;
  3. using Xunit;
  4. namespace Jellyfin.Naming.Tests.Video
  5. {
  6. public class Format3DTests : BaseVideoTest
  7. {
  8. [Fact]
  9. public void TestKodiFormat3D()
  10. {
  11. var options = new NamingOptions();
  12. Test("Super movie.3d.mp4", false, null, options);
  13. Test("Super movie.3d.hsbs.mp4", true, "hsbs", options);
  14. Test("Super movie.3d.sbs.mp4", true, "sbs", options);
  15. Test("Super movie.3d.htab.mp4", true, "htab", options);
  16. Test("Super movie.3d.tab.mp4", true, "tab", options);
  17. Test("Super movie 3d hsbs.mp4", true, "hsbs", options);
  18. }
  19. [Fact]
  20. public void Test3DName()
  21. {
  22. var result =
  23. GetParser().ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv");
  24. Assert.Equal("hsbs", result.Format3D);
  25. Assert.Equal("Oblivion", result.Name);
  26. }
  27. [Fact]
  28. public void TestExpandedFormat3D()
  29. {
  30. // These were introduced for Media Browser 3
  31. // Kodi conventions are preferred but these still need to be supported
  32. var options = new NamingOptions();
  33. Test("Super movie.3d.mp4", false, null, options);
  34. Test("Super movie.3d.hsbs.mp4", true, "hsbs", options);
  35. Test("Super movie.3d.sbs.mp4", true, "sbs", options);
  36. Test("Super movie.3d.htab.mp4", true, "htab", options);
  37. Test("Super movie.3d.tab.mp4", true, "tab", options);
  38. Test("Super movie.hsbs.mp4", true, "hsbs", options);
  39. Test("Super movie.sbs.mp4", true, "sbs", options);
  40. Test("Super movie.htab.mp4", true, "htab", options);
  41. Test("Super movie.tab.mp4", true, "tab", options);
  42. Test("Super movie.sbs3d.mp4", true, "sbs3d", options);
  43. Test("Super movie.3d.mvc.mp4", true, "mvc", options);
  44. Test("Super movie [3d].mp4", false, null, options);
  45. Test("Super movie [hsbs].mp4", true, "hsbs", options);
  46. Test("Super movie [fsbs].mp4", true, "fsbs", options);
  47. Test("Super movie [ftab].mp4", true, "ftab", options);
  48. Test("Super movie [htab].mp4", true, "htab", options);
  49. Test("Super movie [sbs3d].mp4", true, "sbs3d", options);
  50. }
  51. private void Test(string input, bool is3D, string format3D, NamingOptions options)
  52. {
  53. var parser = new Format3DParser(options);
  54. var result = parser.Parse(input);
  55. Assert.Equal(is3D, result.Is3D);
  56. if (format3D == null)
  57. {
  58. Assert.Null(result.Format3D);
  59. }
  60. else
  61. {
  62. Assert.Equal(format3D, result.Format3D, true);
  63. }
  64. }
  65. }
  66. }