Luke Pulverenti 11 years ago
commit 1958096f6b

@ -43,49 +43,49 @@ namespace MediaBrowser.Controller.Library
private static readonly Regex[] EpisodeExpressions = new[]
{
new Regex(
@".*\\[s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3})[^\\]*$",
@".*\\[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\[s|S](?<seasonnumber>\d{1,4})[x,X]?[e|E](?<epnumber>\d{1,3})[^\\]*$",
@".*\\[sS](?<seasonnumber>\d{1,4})[x,X]?[eE](?<epnumber>\d{1,3})[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3}))[^\\]*$",
@".*\\(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>[^\\]*)[s|S](?<seasonnumber>\d{1,4})[x|X|\.]?[e|E](?<epnumber>\d{1,3})[^\\]*$",
@".*\\(?<seriesname>[^\\]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})[^\\]*$",
RegexOptions.Compiled)
};
private static readonly Regex[] MultipleEpisodeExpressions = new[]
{
new Regex(
@".*\\[s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3})([ |-]{1,3}\d{1,4}[e|E|x|X](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[eExX](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\[s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3})([ |-]{1,3}\d{1,4}[x|X][e|E](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\[s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3})([ |-]{0,3}[x|X|e|E](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\[s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3})([ |-]{1,3}[x|E]?[e|E]?(?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\[sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3})(-[xE]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3}))([ |-]{1,3}\d{1,4}[x|X|e|E](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xXeE](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3}))([ |-]{1,3}\d{1,4}[x|X][e|E](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )\d{1,4}[xX][eE](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3}))([ |-]{0,3}[x|X|e|E](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>((?![s|S]?\d{1,4}[x|X]\d{1,3})[^\\])*)?([s|S]?(?<seasonnumber>\d{1,4})[x|X](?<epnumber>\d{1,3}))([ |-]{1,3}[x|X]?[e|E]?(?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\(?<seriesname>((?![sS]?\d{1,4}[xX]\d{1,3})[^\\])*)?([sS]?(?<seasonnumber>\d{1,4})[xX](?<epnumber>\d{1,3}))(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>[^\\]*)[s|S](?<seasonnumber>\d{1,4})[x|X|\.]?[e|E](?<epnumber>\d{1,3})([ |-]{0,3}[x|X|e|E](?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\(?<seriesname>[^\\]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})((-| - )?[xXeE](?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled),
new Regex(
@".*\\(?<seriesname>[^\\]*)[s|S](?<seasonnumber>\d{1,4})[x|X|\.]?[e|E](?<epnumber>\d{1,3})([ |-]{1,3}[x|X]?[e|E]?(?<endingepnumber>\d{1,3}))+[^\\]*$",
@".*\\(?<seriesname>[^\\]*)[sS](?<seasonnumber>\d{1,4})[xX\.]?[eE](?<epnumber>\d{1,3})(-[xX]?[eE]?(?<endingepnumber>\d{1,3}))+[^\\]*$",
RegexOptions.Compiled)
};

@ -64,6 +64,8 @@ namespace MediaBrowser.Tests.Resolvers
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01x02 blah.avi"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01E02 blah.avi"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 1\seriesname S01xE02 blah.avi"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\02x03 - 04 Ep Name.ext"));
Assert.AreEqual(null, TVUtils.GetEndingEpisodeNumberFromFile(@"Season 2\My show name 02x03 - 04 Ep Name.ext"));
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 2\02x03-04-15 - Ep Name.ext"));
@ -77,6 +79,7 @@ namespace MediaBrowser.Tests.Resolvers
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"));

Loading…
Cancel
Save