Format3DTests.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 = VideoResolver.ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions);
  23. Assert.Equal("hsbs", result?.Format3D);
  24. Assert.Equal("Oblivion", result?.Name);
  25. }
  26. [Fact]
  27. public void TestExpandedFormat3D()
  28. {
  29. // These were introduced for Media Browser 3
  30. // Kodi conventions are preferred but these still need to be supported
  31. Test("Super movie.3d.mp4", false, null);
  32. Test("Super movie.3d.hsbs.mp4", true, "hsbs");
  33. Test("Super movie.3d.sbs.mp4", true, "sbs");
  34. Test("Super movie.3d.htab.mp4", true, "htab");
  35. Test("Super movie.3d.tab.mp4", true, "tab");
  36. Test("Super movie.hsbs.mp4", true, "hsbs");
  37. Test("Super movie.sbs.mp4", true, "sbs");
  38. Test("Super movie.htab.mp4", true, "htab");
  39. Test("Super movie.tab.mp4", true, "tab");
  40. Test("Super movie.sbs3d.mp4", true, "sbs3d");
  41. Test("Super movie.3d.mvc.mp4", true, "mvc");
  42. Test("Super movie [3d].mp4", false, null);
  43. Test("Super movie [hsbs].mp4", true, "hsbs");
  44. Test("Super movie [fsbs].mp4", true, "fsbs");
  45. Test("Super movie [ftab].mp4", true, "ftab");
  46. Test("Super movie [htab].mp4", true, "htab");
  47. Test("Super movie [sbs3d].mp4", true, "sbs3d");
  48. }
  49. private void Test(string input, bool is3D, string? format3D)
  50. {
  51. var result = Format3DParser.Parse(input, _namingOptions);
  52. Assert.Equal(is3D, result.Is3D);
  53. if (format3D == null)
  54. {
  55. Assert.Null(result?.Format3D);
  56. }
  57. else
  58. {
  59. Assert.Equal(format3D, result.Format3D, true);
  60. }
  61. }
  62. }
  63. }