From 8879240fc1128f6da99a985b68aef46a940a7ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Alm=C3=A1nzar?= Date: Thu, 27 Jun 2013 22:12:21 -0400 Subject: [PATCH] Fixes #285 - Support tv with four digit seasons --- MediaBrowser.Controller/Library/TVUtils.cs | 42 +++--- MediaBrowser.Tests/Resolvers/TvUtilTests.cs | 150 +++++++++++++++++++- 2 files changed, 166 insertions(+), 26 deletions(-) diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index 03df934cf9..d8a715b0fe 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -43,49 +43,49 @@ namespace MediaBrowser.Controller.Library private static readonly Regex[] EpisodeExpressions = new[] { new Regex( - @".*\\[s|S]?(?\d{1,2})[x|X](?\d{1,3})[^\\]*$", + @".*\\[s|S]?(?\d{1,4})[x|X](?\d{1,3})[^\\]*$", RegexOptions.Compiled), new Regex( - @".*\\[s|S](?\d{1,2})[x,X]?[e|E](?\d{1,3})[^\\]*$", + @".*\\[s|S](?\d{1,4})[x,X]?[e|E](?\d{1,3})[^\\]*$", RegexOptions.Compiled), new Regex( - @".*\\(?((?![s|S]?\d{1,2}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,2})[x|X](?\d{1,3}))[^\\]*$", + @".*\\(?((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,4})[x|X](?\d{1,3}))[^\\]*$", RegexOptions.Compiled), new Regex( - @".*\\(?[^\\]*)[s|S](?\d{1,2})[x|X|\.]?[e|E](?\d{1,3})[^\\]*$", + @".*\\(?[^\\]*)[s|S](?\d{1,4})[x|X|\.]?[e|E](?\d{1,3})[^\\]*$", RegexOptions.Compiled) }; private static readonly Regex[] MultipleEpisodeExpressions = new[] { new Regex( - @".*\\[s|S]?(?\d{1,2})[x|X](?\d{1,3})([ |-]{1,3}\d{1,2}[e|E|x|X](?\d{1,3}))+[^\\]*$", + @".*\\[s|S]?(?\d{1,4})[x|X](?\d{1,3})([ |-]{1,3}\d{1,4}[e|E|x|X](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\[s|S]?(?\d{1,2})[x|X](?\d{1,3})([ |-]{1,3}\d{1,2}[x|X][e|E](?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\[s|S]?(?\d{1,4})[x|X](?\d{1,3})([ |-]{1,3}\d{1,4}[x|X][e|E](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\[s|S]?(?\d{1,2})[x|X](?\d{1,3})([ |-]{0,3}[x|X|e|E](?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\[s|S]?(?\d{1,4})[x|X](?\d{1,3})([ |-]{0,3}[x|X|e|E](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\[s|S]?(?\d{1,2})[x|X](?\d{1,3})([ |-]{1,3}[x|E]?[e|E]?(?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\[s|S]?(?\d{1,4})[x|X](?\d{1,3})([ |-]{1,3}[x|E]?[e|E]?(?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), new Regex( - @".*\\(?((?![s|S]?\d{1,2}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,2})[x|X](?\d{1,3}))([ |-]{1,3}\d{1,2}[x|X|e|E](?\d{1,3}))+[^\\]*$", + @".*\\(?((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,4})[x|X](?\d{1,3}))([ |-]{1,3}\d{1,4}[x|X|e|E](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\(?((?![s|S]?\d{1,2}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,2})[x|X](?\d{1,3}))([ |-]{1,3}\d{1,2}[x|X][e|E](?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\(?((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,4})[x|X](?\d{1,3}))([ |-]{1,3}\d{1,4}[x|X][e|E](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\(?((?![s|S]?\d{1,2}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,2})[x|X](?\d{1,3}))([ |-]{0,3}[x|X|e|E](?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\(?((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,4})[x|X](?\d{1,3}))([ |-]{0,3}[x|X|e|E](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\(?((?![s|S]?\d{1,2}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,2})[x|X](?\d{1,3}))([ |-]{1,3}[x|X]?[e|E]?(?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\(?((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?\d{1,4})[x|X](?\d{1,3}))([ |-]{1,3}[x|X]?[e|E]?(?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), new Regex( - @".*\\(?[^\\]*)[s|S](?\d{1,2})[x|X|\.]?[e|E](?\d{1,3})([ |-]{0,3}[x|X|e|E](?\d{1,3}))+[^\\]*$", + @".*\\(?[^\\]*)[s|S](?\d{1,4})[x|X|\.]?[e|E](?\d{1,3})([ |-]{0,3}[x|X|e|E](?\d{1,3}))+[^\\]*$", RegexOptions.Compiled), - new Regex( - @".*\\(?[^\\]*)[s|S](?\d{1,2})[x|X|\.]?[e|E](?\d{1,3})([ |-]{1,3}[x|X]?[e|E]?(?\d{1,3}))+[^\\]*$", + new Regex( + @".*\\(?[^\\]*)[s|S](?\d{1,4})[x|X|\.]?[e|E](?\d{1,3})([ |-]{1,3}[x|X]?[e|E]?(?\d{1,3}))+[^\\]*$", RegexOptions.Compiled) }; diff --git a/MediaBrowser.Tests/Resolvers/TvUtilTests.cs b/MediaBrowser.Tests/Resolvers/TvUtilTests.cs index 7d5b10322a..51229a22c0 100644 --- a/MediaBrowser.Tests/Resolvers/TvUtilTests.cs +++ b/MediaBrowser.Tests/Resolvers/TvUtilTests.cs @@ -29,6 +29,28 @@ namespace MediaBrowser.Tests.Resolvers Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext", true)); Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4", true)); Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4", true)); + + //Four Digits seasons + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009x02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009E02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009xE02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname 2009x02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009x02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009E02 blah.avi", true)); + Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\seriesname S2009xE02 blah.avi", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03-04-15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03-E15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x03x04x15 - Ep Name.ext", true)); + Assert.AreEqual(03, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext", true)); + Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4", true)); + Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4", true)); } [TestMethod] @@ -44,15 +66,133 @@ namespace MediaBrowser.Tests.Resolvers Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01xE02 blah.avi")); Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext")); Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext")); - Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03-E15 - Ep Name.ext")); - Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext")); Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02x03-04-15 - Ep Name.ext")); Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext")); - Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4")); - Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4")); - Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03x04x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03-E15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext")); Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext")); Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\02x03x04x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext")); + Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4")); + Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4")); + + //Four Digits seasons + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009x02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009E02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009xE02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname 2009x02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009x02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009E02 blah.avi")); + Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\seriesname S2009xE02 blah.avi")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03-04-15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03-E15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\2009x03x04x15 - Ep Name.ext")); + Assert.AreEqual(15, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext")); + Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4")); + Assert.AreEqual(26, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4")); + + } + + [TestMethod] + public void TestGetSeasonNumberFromPath() { + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 02")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 1")); + + //Four Digits seasons + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromPath(@"\Drive\Season 2009")); + } + + [TestMethod] + public void TestGetSeasonNumberFromEpisodeFile() + { + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\01x02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01x02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01E02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01xE02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname 01x02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01x02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01E02 blah.avi")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\seriesname S01xE02 blah.avi")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\Elementary - 02x03 - 02x04 - 02x15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\02x03 - 02x04 - 02x15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\02x03-04-15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2\Elementary - 02x03-04-15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03-E15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03-E15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\02x03x04x15 - Ep Name.ext")); + Assert.AreEqual(2, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 02\Elementary - 02x03x04x15 - Ep Name.ext")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\Elementary - S01E23-E24-E26 - The Woman.mp4")); + Assert.AreEqual(1, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4")); + + //Four Digits seasons + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009x02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009E02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009xE02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname 2009x02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009x02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009E02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\seriesname S2009xE02 blah.avi")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03 - 2009x04 - 2009x15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03-04-15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03-04-15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03-E15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03-E15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03 - x04 - x15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\2009x03x04x15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - 2009x03x04x15 - Ep Name.ext")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\Elementary - S2009E23-E24-E26 - The Woman.mp4")); + Assert.AreEqual(2009, TVUtils.GetSeasonNumberFromEpisodeFile(@"Season 2009\S2009E23-E24-E26 - The Woman.mp4")); + } } }