From 26d3d9dcd6fb746ed0e0c68a301b2d96eb2013af Mon Sep 17 00:00:00 2001 From: Cyberlane Date: Fri, 8 Nov 2013 19:03:01 +0000 Subject: [PATCH] Small tweaks based on feedback from @markus101 --- .../Parser/Model/ParsedEpisodeInfo.cs | 2 +- src/NzbDrone.Core/Parser/Parser.cs | 47 +++++++++---------- src/NzbDrone.Core/Parser/ParsingService.cs | 4 +- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs index ee9e8f94b..7913742d7 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Parser.Model public bool IsAbsoluteNumbering() { - return AbsoluteEpisodeNumbers.Length > 0; + return AbsoluteEpisodeNumbers.Any(); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 419baa5c0..17b1491d3 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -246,7 +246,7 @@ namespace NzbDrone.Core.Parser { SeasonNumber = seasons.First(), EpisodeNumbers = new int[0], - AbsoluteEpisodeNumbers = new int[0] + AbsoluteEpisodeNumbers = new int[0] }; foreach (Match matchGroup in matchCollection) @@ -255,36 +255,31 @@ namespace NzbDrone.Core.Parser var absoluteEpisodeCaptures = matchGroup.Groups["absoluteepisode"].Captures.Cast().ToList(); //Allows use to return a list of 0 episodes (We can handle that as a full season release) - var eps = episodeCaptures.Any(); - var epsAbs = absoluteEpisodeCaptures.Any(); - if (eps || epsAbs) + if (episodeCaptures.Any()) { - if (eps) + var first = Convert.ToInt32(episodeCaptures.First().Value); + var last = Convert.ToInt32(episodeCaptures.Last().Value); + + if (first > last) { - var first = Convert.ToInt32(episodeCaptures.First().Value); - var last = Convert.ToInt32(episodeCaptures.Last().Value); - - if (first > last) - { - return null; - } - - var count = last - first + 1; - result.EpisodeNumbers = Enumerable.Range(first, count).ToArray(); + return null; } - if (epsAbs) + + var count = last - first + 1; + result.EpisodeNumbers = Enumerable.Range(first, count).ToArray(); + } + else if (absoluteEpisodeCaptures.Any()) + { + var first = Convert.ToInt32(absoluteEpisodeCaptures.First().Value); + var last = Convert.ToInt32(absoluteEpisodeCaptures.Last().Value); + + if (first > last) { - var first = Convert.ToInt32(absoluteEpisodeCaptures.First().Value); - var last = Convert.ToInt32(absoluteEpisodeCaptures.Last().Value); - - if (first > last) - { - return null; - } - - var count = last - first + 1; - result.AbsoluteEpisodeNumbers = Enumerable.Range(first, count).ToArray(); + return null; } + + var count = last - first + 1; + result.AbsoluteEpisodeNumbers = Enumerable.Range(first, count).ToArray(); } else { diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index aa474954b..ee544d789 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -137,11 +137,9 @@ namespace NzbDrone.Core.Parser if (episodeInfo != null) { - _logger.Info("Using absolute episode number {0} for: {1} - Scene: {2}x{3:00} - TVDB: {4}x{5:00}", + _logger.Info("Using absolute episode number {0} for: {1} - TVDB: {2}x{3:00}", absoluteEpisodeNumber, series.Title, - episodeInfo.SceneSeasonNumber, - episodeInfo.SceneEpisodeNumber, episodeInfo.SeasonNumber, episodeInfo.EpisodeNumber); result.Add(episodeInfo);