1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-25 01:06:30 +00:00

Fixed parser being too greedy.

This commit is contained in:
Mark McDowall 2011-12-11 23:34:58 -08:00
parent 75cfb7e044
commit 30e30451c4

View file

@ -24,11 +24,11 @@ namespace NzbDrone.Core
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Multi-episode (S01E05E06, S01E05-06, etc) //Multi-episode (S01E05E06, S01E05-06, etc)
new Regex(@"^(?<title>.+?)(?:\W+S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|[ex]|\s){1,2}(?<episode>\d{1,2}(?!\d+)))+){2,}\W?(?!\\)", new Regex(@"^(?<title>.+?)(?:\W+S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|[ex]|\s){1,2}(?<episode>\d{2}(?!\d+)))+){2,}\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Single episodes (S01E05, 1x056, etc) //Single episodes (S01E05, 1x05, etc)
new Regex(@"^(?<title>.+?)(?:\W+S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|[ex]|\s){1,2}(?<episode>\d{1,2}(?!\d+)))+)\W?(?!\\)", new Regex(@"^(?<title>.+?)(?:\W+S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|[ex]|\s){1,2}(?<episode>\d{2}(?!\d+)))+)\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//No Title - Single episodes or multi-episode (S01E05E06, S01E05-06, etc) //No Title - Single episodes or multi-episode (S01E05E06, S01E05-06, etc)
@ -61,7 +61,6 @@ namespace NzbDrone.Core
private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?<unit>GB|MB|GiB|MiB)", private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?<unit>GB|MB|GiB|MiB)",
RegexOptions.IgnoreCase | RegexOptions.Compiled); RegexOptions.IgnoreCase | RegexOptions.Compiled);
internal static EpisodeParseResult ParsePath(string path) internal static EpisodeParseResult ParsePath(string path)
{ {
var fileInfo = new FileInfo(path); var fileInfo = new FileInfo(path);
@ -77,7 +76,6 @@ namespace NzbDrone.Core
return result; return result;
} }
internal static EpisodeParseResult ParseTitle(string title) internal static EpisodeParseResult ParseTitle(string title)
{ {
try try