aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/BaseVideoTest.cs8
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs172
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/CleanStringTests.cs160
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs1
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/StackTests.cs26
5 files changed, 83 insertions, 284 deletions
diff --git a/tests/Jellyfin.Naming.Tests/Video/BaseVideoTest.cs b/tests/Jellyfin.Naming.Tests/Video/BaseVideoTest.cs
index b993e241c..0c2978aca 100644
--- a/tests/Jellyfin.Naming.Tests/Video/BaseVideoTest.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/BaseVideoTest.cs
@@ -5,11 +5,9 @@ namespace Jellyfin.Naming.Tests.Video
{
public abstract class BaseVideoTest
{
- protected VideoResolver GetParser()
- {
- var options = new NamingOptions();
+ private readonly NamingOptions _namingOptions = new NamingOptions();
- return new VideoResolver(options);
- }
+ protected VideoResolver GetParser()
+ => new VideoResolver(_namingOptions);
}
}
diff --git a/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs b/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs
index bba73ad91..a2ef2dcd6 100644
--- a/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs
@@ -1,143 +1,59 @@
using System.IO;
+using Emby.Naming.Common;
+using Emby.Naming.Video;
using Xunit;
namespace Jellyfin.Naming.Tests.Video
{
- public class CleanDateTimeTests : BaseVideoTest
+ public sealed class CleanDateTimeTests
{
- // FIXME
- // [Fact]
- public void TestCleanDateTime()
- {
- Test(@"The Wolf of Wall Street (2013).mkv", "The Wolf of Wall Street", 2013);
- Test(@"The Wolf of Wall Street 2 (2013).mkv", "The Wolf of Wall Street 2", 2013);
- Test(@"The Wolf of Wall Street - 2 (2013).mkv", "The Wolf of Wall Street - 2", 2013);
- Test(@"The Wolf of Wall Street 2001 (2013).mkv", "The Wolf of Wall Street 2001", 2013);
-
- Test(@"300 (2006).mkv", "300", 2006);
- Test(@"d:/movies/300 (2006).mkv", "300", 2006);
- Test(@"300 2 (2006).mkv", "300 2", 2006);
- Test(@"300 - 2 (2006).mkv", "300 - 2", 2006);
- Test(@"300 2001 (2006).mkv", "300 2001", 2006);
-
- Test(@"curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", "curse.of.chucky", 2013);
- Test(@"curse.of.chucky.2013.stv.unrated.multi.2160p.bluray.x264-rough", "curse.of.chucky", 2013);
-
- Test(@"/server/Movies/300 (2007)/300 (2006).bluray.disc", "300", 2006);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTime1()
- {
- Test(@"Arrival.2016.2160p.Blu-Ray.HEVC.mkv", "Arrival", 2016);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithoutFileExtension()
- {
- Test(@"The Wolf of Wall Street (2013)", "The Wolf of Wall Street", 2013);
- Test(@"The Wolf of Wall Street 2 (2013)", "The Wolf of Wall Street 2", 2013);
- Test(@"The Wolf of Wall Street - 2 (2013)", "The Wolf of Wall Street - 2", 2013);
- Test(@"The Wolf of Wall Street 2001 (2013)", "The Wolf of Wall Street 2001", 2013);
-
- Test(@"300 (2006)", "300", 2006);
- Test(@"d:/movies/300 (2006)", "300", 2006);
- Test(@"300 2 (2006)", "300 2", 2006);
- Test(@"300 - 2 (2006)", "300 - 2", 2006);
- Test(@"300 2001 (2006)", "300 2001", 2006);
-
- Test(@"/server/Movies/300 (2007)/300 (2006)", "300", 2006);
- Test(@"/server/Movies/300 (2007)/300 (2006).mkv", "300", 2006);
- }
-
- [Fact]
- public void TestCleanDateTimeWithoutDate()
- {
- Test(@"American.Psycho.mkv", "American.Psycho.mkv", null);
- Test(@"American Psycho.mkv", "American Psycho.mkv", null);
- }
-
- [Fact]
- public void TestCleanDateTimeWithBracketedName()
- {
- Test(@"[rec].mkv", "[rec].mkv", null);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithoutExtension()
- {
- Test(@"St. Vincent (2014)", "St. Vincent", 2014);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithoutDate1()
- {
- Test("Super movie(2009).mp4", "Super movie", 2009);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithoutParenthesis()
- {
- Test("Drug War 2013.mp4", "Drug War", 2013);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithMultipleYears()
- {
- Test("My Movie (1997) - GreatestReleaseGroup 2019.mp4", "My Movie", 1997);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithYearAndResolution()
- {
- Test("First Man 2018 1080p.mkv", "First Man", 2018);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithYearAndResolution1()
- {
- Test("First Man (2018) 1080p.mkv", "First Man", 2018);
- }
-
- // FIXME
- // [Fact]
- public void TestCleanDateTimeWithSceneRelease()
- {
- Test("Maximum Ride - 2016 - WEBDL-1080p - x264 AC3.mkv", "Maximum Ride", 2016);
- }
-
- // FIXME
- // [Fact]
- public void TestYearInBrackets()
- {
- Test("Robin Hood [Multi-Subs] [2018].mkv", "Robin Hood", 2018);
- }
-
- private void Test(string input, string expectedName, int? expectedYear)
+ private readonly NamingOptions _namingOptions = new NamingOptions();
+
+ [Theory]
+ [InlineData(@"The Wolf of Wall Street (2013).mkv", "The Wolf of Wall Street", 2013)]
+ [InlineData(@"The Wolf of Wall Street 2 (2013).mkv", "The Wolf of Wall Street 2", 2013)]
+ [InlineData(@"The Wolf of Wall Street - 2 (2013).mkv", "The Wolf of Wall Street - 2", 2013)]
+ [InlineData(@"The Wolf of Wall Street 2001 (2013).mkv", "The Wolf of Wall Street 2001", 2013)]
+ [InlineData(@"300 (2006).mkv", "300", 2006)]
+ [InlineData(@"d:/movies/300 (2006).mkv", "300", 2006)]
+ [InlineData(@"300 2 (2006).mkv", "300 2", 2006)]
+ [InlineData(@"300 - 2 (2006).mkv", "300 - 2", 2006)]
+ [InlineData(@"300 2001 (2006).mkv", "300 2001", 2006)]
+ [InlineData(@"curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", "curse.of.chucky", 2013)]
+ [InlineData(@"curse.of.chucky.2013.stv.unrated.multi.2160p.bluray.x264-rough", "curse.of.chucky", 2013)]
+ [InlineData(@"/server/Movies/300 (2007)/300 (2006).bluray.disc", "300", 2006)]
+ [InlineData(@"Arrival.2016.2160p.Blu-Ray.HEVC.mkv", "Arrival", 2016)]
+ [InlineData(@"The Wolf of Wall Street (2013)", "The Wolf of Wall Street", 2013)]
+ [InlineData(@"The Wolf of Wall Street 2 (2013)", "The Wolf of Wall Street 2", 2013)]
+ [InlineData(@"The Wolf of Wall Street - 2 (2013)", "The Wolf of Wall Street - 2", 2013)]
+ [InlineData(@"The Wolf of Wall Street 2001 (2013)", "The Wolf of Wall Street 2001", 2013)]
+ [InlineData(@"300 (2006)", "300", 2006)]
+ [InlineData(@"d:/movies/300 (2006)", "300", 2006)]
+ [InlineData(@"300 2 (2006)", "300 2", 2006)]
+ [InlineData(@"300 - 2 (2006)", "300 - 2", 2006)]
+ [InlineData(@"300 2001 (2006)", "300 2001", 2006)]
+ [InlineData(@"/server/Movies/300 (2007)/300 (2006)", "300", 2006)]
+ [InlineData(@"/server/Movies/300 (2007)/300 (2006).mkv", "300", 2006)]
+ [InlineData(@"American.Psycho.mkv", "American.Psycho.mkv", null)]
+ [InlineData(@"American Psycho.mkv", "American Psycho.mkv", null)]
+ [InlineData(@"[rec].mkv", "[rec].mkv", null)]
+ [InlineData(@"St. Vincent (2014)", "St. Vincent", 2014)]
+ [InlineData("Super movie(2009).mp4", "Super movie", 2009)]
+ // FIXME: [InlineData("Drug War 2013.mp4", "Drug War", 2013)]
+ [InlineData("My Movie (1997) - GreatestReleaseGroup 2019.mp4", "My Movie", 1997)]
+ // FIXME: [InlineData("First Man 2018 1080p.mkv", "First Man", 2018)]
+ [InlineData("First Man (2018) 1080p.mkv", "First Man", 2018)]
+ // FIXME: [InlineData("Maximum Ride - 2016 - WEBDL-1080p - x264 AC3.mkv", "Maximum Ride", 2016)]
+ // FIXME: [InlineData("Robin Hood [Multi-Subs] [2018].mkv", "Robin Hood", 2018)]
+ [InlineData(@"3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv", "3.Days.to.Kill", 2014)] // In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
+ public void CleanDateTimeTest(string input, string expectedName, int? expectedYear)
{
input = Path.GetFileName(input);
- var result = GetParser().CleanDateTime(input);
+ var result = new VideoResolver(_namingOptions).CleanDateTime(input);
Assert.Equal(expectedName, result.Name, true);
Assert.Equal(expectedYear, result.Year);
}
-
- // FIXME
- // [Fact]
- public void TestCleanDateAndStringsSequence()
- {
- // In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
-
- Test(@"3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv", "3.Days.to.Kill", 2014);
- }
}
}
diff --git a/tests/Jellyfin.Naming.Tests/Video/CleanStringTests.cs b/tests/Jellyfin.Naming.Tests/Video/CleanStringTests.cs
index cd90ac236..fde06c5a1 100644
--- a/tests/Jellyfin.Naming.Tests/Video/CleanStringTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/CleanStringTests.cs
@@ -1,133 +1,45 @@
using System;
-using System.Globalization;
+using Emby.Naming.Common;
+using Emby.Naming.Video;
using Xunit;
namespace Jellyfin.Naming.Tests.Video
{
- public class CleanStringTests : BaseVideoTest
+ public sealed class CleanStringTests
{
- // FIXME
- // [Fact]
- public void TestCleanString()
- {
- Test("Super movie 480p.mp4", "Super movie");
- Test("Super movie 480p 2001.mp4", "Super movie");
- Test("Super movie [480p].mp4", "Super movie");
- Test("480 Super movie [tmdbid=12345].mp4", "480 Super movie");
- }
-
- // FIXME
- // [Fact]
- public void TestCleanString1()
- {
- Test("Super movie(2009).mp4", "Super movie(2009).mp4");
- }
-
- // FIXME
- // [Fact]
- public void TestCleanString2()
- {
- Test("Run lola run (lola rennt) (2009).mp4", "Run lola run (lola rennt) (2009).mp4");
- }
-
- // FIXME
- // [Fact]
- public void TestStringWithoutDate()
- {
- Test(@"American.Psycho.mkv", "American.Psycho.mkv");
- Test(@"American Psycho.mkv", "American Psycho.mkv");
- }
-
- // FIXME
- // [Fact]
- public void TestNameWithBrackets()
- {
- Test(@"[rec].mkv", "[rec].mkv");
- }
-
- // FIXME
- // [Fact]
- public void Test4k()
- {
- Test("Crouching.Tiger.Hidden.Dragon.4k.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestUltraHd()
- {
- Test("Crouching.Tiger.Hidden.Dragon.UltraHD.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestUHd()
- {
- Test("Crouching.Tiger.Hidden.Dragon.UHD.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestHDR()
- {
- Test("Crouching.Tiger.Hidden.Dragon.HDR.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestHDC()
- {
- Test("Crouching.Tiger.Hidden.Dragon.HDC.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestHDC1()
- {
- Test("Crouching.Tiger.Hidden.Dragon-HDC.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestBDrip()
- {
- Test("Crouching.Tiger.Hidden.Dragon.BDrip.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestBDripHDC()
- {
- Test("Crouching.Tiger.Hidden.Dragon.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestMulti()
- {
- Test("Crouching.Tiger.Hidden.Dragon.4K.UltraHD.HDR.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon");
- }
-
- // FIXME
- // [Fact]
- public void TestLeadingBraces()
- {
- // Not actually supported, just reported by a user
- Test("[0004] - After The Sunset.el.mkv", "After The Sunset");
- }
-
- // FIXME
- // [Fact]
- public void TestTrailingBraces()
- {
- Test("After The Sunset - [0004].mkv", "After The Sunset");
- }
-
- private void Test(string input, string expectedName)
- {
- var result = GetParser().CleanString(input).ToString();
-
- Assert.Equal(expectedName, result, true);
+ private readonly NamingOptions _namingOptions = new NamingOptions();
+
+ [Theory]
+ [InlineData("Super movie 480p.mp4", "Super movie")]
+ [InlineData("Super movie 480p 2001.mp4", "Super movie")]
+ [InlineData("Super movie [480p].mp4", "Super movie")]
+ [InlineData("480 Super movie [tmdbid=12345].mp4", "480 Super movie")]
+ [InlineData("Super movie(2009).mp4", "Super movie(2009).mp4")]
+ [InlineData("Run lola run (lola rennt) (2009).mp4", "Run lola run (lola rennt) (2009).mp4")]
+ [InlineData(@"American.Psycho.mkv", "American.Psycho.mkv")]
+ [InlineData(@"American Psycho.mkv", "American Psycho.mkv")]
+ [InlineData(@"[rec].mkv", "[rec].mkv")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.4k.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.UltraHD.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.UHD.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.HDR.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.BDrip.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ [InlineData("Crouching.Tiger.Hidden.Dragon.4K.UltraHD.HDR.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
+ // FIXME: [InlineData("After The Sunset - [0004].mkv", "After The Sunset")]
+ public void CleanStringTest(string input, string expectedName)
+ {
+ if (new VideoResolver(_namingOptions).TryCleanString(input, out ReadOnlySpan<char> newName))
+ {
+ // TODO: compare spans when XUnit supports it
+ Assert.Equal(expectedName, newName.ToString());
+ }
+ else
+ {
+ Assert.Equal(expectedName, input);
+ }
}
}
}
diff --git a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
index b8674ec49..b8fbb2cb2 100644
--- a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
@@ -62,7 +62,6 @@ namespace Jellyfin.Naming.Tests.Video
[Fact]
public void TestMultiEdition3()
{
- // This is currently not supported and will fail, but we should try to figure it out
var files = new[]
{
@"/movies/The Phantom of the Opera (1925)/The Phantom of the Opera (1925) - 1925 version.mkv",
diff --git a/tests/Jellyfin.Naming.Tests/Video/StackTests.cs b/tests/Jellyfin.Naming.Tests/Video/StackTests.cs
index 5faef0e3d..5c121d738 100644
--- a/tests/Jellyfin.Naming.Tests/Video/StackTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/StackTests.cs
@@ -383,32 +383,6 @@ namespace Jellyfin.Naming.Tests.Video
}
[Fact]
- public void TestDirectories2()
- {
- //TestDirectory(@"blah blah", false, @"blah blah");
- //TestDirectory(@"d:/music/weezer/03 Pinkerton", false, "03 Pinkerton");
- //TestDirectory(@"d:/music/michael jackson/Bad (2012 Remaster)", false, "Bad (2012 Remaster)");
-
- //TestDirectory(@"blah blah - cd1", true, "blah blah");
- //TestDirectory(@"blah blah - disc1", true, "blah blah");
- //TestDirectory(@"blah blah - disk1", true, "blah blah");
- //TestDirectory(@"blah blah - pt1", true, "blah blah");
- //TestDirectory(@"blah blah - part1", true, "blah blah");
- //TestDirectory(@"blah blah - dvd1", true, "blah blah");
-
- //// Add a space
- //TestDirectory(@"blah blah - cd 1", true, "blah blah");
- //TestDirectory(@"blah blah - disc 1", true, "blah blah");
- //TestDirectory(@"blah blah - disk 1", true, "blah blah");
- //TestDirectory(@"blah blah - pt 1", true, "blah blah");
- //TestDirectory(@"blah blah - part 1", true, "blah blah");
- //TestDirectory(@"blah blah - dvd 1", true, "blah blah");
-
- //// Not case sensitive
- //TestDirectory(@"blah blah - Disc1", true, "blah blah");
- }
-
- [Fact]
public void TestNamesWithoutParts()
{
// No stacking here because there is no part/disc/etc