This commit is contained in:
Luke Pulverenti 2014-07-03 22:23:05 -04:00
commit a4d5b30bd0
2 changed files with 18 additions and 4 deletions

View File

@ -98,19 +98,19 @@ namespace MediaBrowser.Controller.Library
private static readonly Regex[] EpisodeExpressionsWithoutSeason =
{
new Regex(
@".*[\\\/](?<epnumber>\d{1,3})\.\w+$",
@".*[\\\/](?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.\w+$",
RegexOptions.Compiled),
// "01.avi"
new Regex(
@".*(\\|\/)(?<epnumber>\d{1,2})\s?-\s?[^\\\/]*$",
@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\s?-\s?[^\\\/]*$",
RegexOptions.Compiled),
// "01 - blah.avi", "01-blah.avi"
new Regex(
@".*(\\|\/)(?<epnumber>\d{1,2})\.[^\\\/]+$",
@".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.[^\\\/]+$",
RegexOptions.Compiled),
// "01.blah.avi"
new Regex(
@".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})[^\\\/]*$",
@".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$",
RegexOptions.Compiled),
// "blah - 01.avi", "blah 2 - 01.avi", "blah - 01 blah.avi", "blah 2 - 01 blah", "blah - 01 - blah.avi", "blah 2 - 01 - blah"
};
@ -284,6 +284,12 @@ namespace MediaBrowser.Controller.Library
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
}
foreach (var r in EpisodeExpressionsWithoutSeason)
{
var m = r.Match(fl);
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
}
return null;
}

View File

@ -31,6 +31,7 @@ namespace MediaBrowser.Tests.Resolvers
Assert.AreEqual(23, TVUtils.GetEpisodeNumberFromFile(@"Season 1\S01E23-E24-E26 - The Woman.mp4", true));
Assert.AreEqual(9, TVUtils.GetEpisodeNumberFromFile(@"Season 25\The Simpsons.S25E09.Steal this episode.mp4", true));
Assert.AreEqual(8, TVUtils.GetEpisodeNumberFromFile(@"The Simpsons\The Simpsons.S25E08.Steal this episode.mp4", false));
Assert.AreEqual(136, TVUtils.GetEpisodeNumberFromFile(@"Season 2\[HorribleSubs] Hunter X Hunter - 136 [720p].mkv",true));
//Four Digits seasons
Assert.AreEqual(02, TVUtils.GetEpisodeNumberFromFile(@"Season 2009\2009x02 blah.avi", true));
@ -128,6 +129,13 @@ namespace MediaBrowser.Tests.Resolvers
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02 - blah 14 blah.avi"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02 - blah-02 a.avi"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02.avi"));
Assert.AreEqual(3, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02-03 - blah.avi"));
Assert.AreEqual(4, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02-04 - blah 14 blah.avi"));
Assert.AreEqual(5, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\02-05 - blah-02 a.avi"));
Assert.AreEqual(4, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02-04.avi"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\[HorribleSubs] Hunter X Hunter - 136 [720p].mkv"));
}
[TestMethod]