Format3DTests.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Emby.Naming.Common;
  2. using Emby.Naming.Video;
  3. using Xunit;
  4. namespace Jellyfin.Naming.Tests.Video
  5. {
  6. public class Format3DTests
  7. {
  8. private readonly NamingOptions _namingOptions = new NamingOptions();
  9. [Fact]
  10. public void TestKodiFormat3D()
  11. {
  12. Test("Super movie.3d.mp4", false, null);
  13. Test("Super movie.3d.hsbs.mp4", true, "hsbs");
  14. Test("Super movie.3d.sbs.mp4", true, "sbs");
  15. Test("Super movie.3d.htab.mp4", true, "htab");
  16. Test("Super movie.3d.tab.mp4", true, "tab");
  17. Test("Super movie 3d hsbs.mp4", true, "hsbs");
  18. }
  19. [Fact]
  20. public void Test3DName()
  21. {
  22. var result =
  23. new VideoResolver(_namingOptions).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. Test("Super movie.3d.mp4", false, null);
  33. Test("Super movie.3d.hsbs.mp4", true, "hsbs");
  34. Test("Super movie.3d.sbs.mp4", true, "sbs");
  35. Test("Super movie.3d.htab.mp4", true, "htab");
  36. Test("Super movie.3d.tab.mp4", true, "tab");
  37. Test("Super movie.hsbs.mp4", true, "hsbs");
  38. Test("Super movie.sbs.mp4", true, "sbs");
  39. Test("Super movie.htab.mp4", true, "htab");
  40. Test("Super movie.tab.mp4", true, "tab");
  41. Test("Super movie.sbs3d.mp4", true, "sbs3d");
  42. Test("Super movie.3d.mvc.mp4", true, "mvc");
  43. Test("Super movie [3d].mp4", false, null);
  44. Test("Super movie [hsbs].mp4", true, "hsbs");
  45. Test("Super movie [fsbs].mp4", true, "fsbs");
  46. Test("Super movie [ftab].mp4", true, "ftab");
  47. Test("Super movie [htab].mp4", true, "htab");
  48. Test("Super movie [sbs3d].mp4", true, "sbs3d");
  49. }
  50. private void Test(string input, bool is3D, string? format3D)
  51. {
  52. var parser = new Format3DParser(_namingOptions);
  53. var result = parser.Parse(input);
  54. Assert.Equal(is3D, result.Is3D);
  55. if (format3D == null)
  56. {
  57. Assert.Null(result.Format3D);
  58. }
  59. else
  60. {
  61. Assert.Equal(format3D, result.Format3D, true);
  62. }
  63. }
  64. }
  65. }