mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
Merge pull request #863 from lalmanzar/master
add multi-episode support for filenames without seasons
This commit is contained in:
commit
27b2af7705
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user