From a2df6e0e36a05e50f09a3b2e2df9408661b1e6ea Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 8 Nov 2019 19:59:48 +0100 Subject: [PATCH] Fix naming tests --- Emby.Naming/Common/NamingOptions.cs | 13 ++++++--- Emby.Naming/Emby.Naming.csproj | 8 +++--- .../Jellyfin.Common.Tests.csproj | 2 +- .../EpisodePathParserTest.cs | 27 ++++++++++--------- .../Jellyfin.Naming.Tests.csproj | 9 +++---- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 9cf430daf7..bb214e9f26 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -311,6 +311,12 @@ namespace Emby.Naming.Common } }, + // "Foo Bar 889" + new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?(\w+\s*?)*)\s(?\d{1,3})(-(?\d{2,3}))*[^\\\/]*$") + { + IsNamed = true + }, + new EpisodeExpression("[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$") { SupportsAbsoluteEpisodeNumbers = true @@ -328,9 +334,10 @@ namespace Emby.Naming.Common // *** End Kodi Standard Naming -                // [bar] Foo - 1 [baz] -                new EpisodeExpression(@".*?(\[.*?\])+.*?(?(\w+\s)+?)[-\s_]+(?\d+).*$"){ - IsNamed=false, +                // [bar] Foo - 1 [baz] + new EpisodeExpression(@".*?(\[.*?\])+.*?(?(\w+\s*?)+?)[-\s_]+(?\d+).*$") + { + IsNamed = true }, new EpisodeExpression(@".*(\\|\/)[sS]?(?\d+)[xX](?\d+)[^\\\/]*$") { diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj index a23fa3df79..fd0773df53 100644 --- a/Emby.Naming/Emby.Naming.csproj +++ b/Emby.Naming/Emby.Naming.csproj @@ -23,10 +23,10 @@ - - - - + + + + diff --git a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj index bb40985a49..aa005b31d0 100644 --- a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj +++ b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs b/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs index 28ccd6df1d..dd1e042155 100644 --- a/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs +++ b/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs @@ -1,8 +1,9 @@ -namespace Emby.Naming.TV -{ - using Emby.Naming.Common; - using Xunit; +using Emby.Naming.Common; +using Emby.Naming.TV; +using Xunit; +namespace Jellyfin.Naming.Tests +{ public class EpisodePathParserTest { [Theory] @@ -21,8 +22,8 @@ namespace Emby.Naming.TV Assert.Equal(season, res.SeasonNumber); Assert.Equal(episode, res.EpisodeNumber); - //testing other paths delimeter - var res2 = p.Parse(path.Replace("/", "\\"), false); + // testing other paths delimeter + var res2 = p.Parse(path.Replace('/', '\\'), false); Assert.True(res2.Success); Assert.Equal(name, res2.SeriesName); Assert.Equal(season, res2.SeasonNumber); @@ -31,24 +32,24 @@ namespace Emby.Naming.TV [Theory] [InlineData("/media/Foo/Foo 889", "Foo", 889)] - [InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)] + [InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)] public void ParseEpisodeWithoutSeason(string path, string name, int episode) { NamingOptions o = new NamingOptions(); EpisodePathParser p = new EpisodePathParser(o); - var res = p.Parse(path, true, null, null, true); + var res = p.Parse(path, true, fillExtendedInfo: true); Assert.True(res.Success); Assert.Equal(name, res.SeriesName); - Assert.True(res.SeasonNumber == null); + Assert.Null(res.SeasonNumber); Assert.Equal(episode, res.EpisodeNumber); - //testing other paths delimeter - var res2 = p.Parse(path.Replace("/", "\\"), false, null, null, true); + // testing other paths delimeter + var res2 = p.Parse(path.Replace('/', '\\'), false, fillExtendedInfo: false); Assert.True(res2.Success); Assert.Equal(name, res2.SeriesName); - Assert.True(res2.SeasonNumber == null); + Assert.Null(res2.SeasonNumber); Assert.Equal(episode, res2.EpisodeNumber); } } -} \ No newline at end of file +} diff --git a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj index f5e1513489..fe1518131c 100644 --- a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj +++ b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj @@ -2,15 +2,14 @@ netcoreapp3.0 - false - - - - + + + +