From 2dbf095fd515c0404c3473ea832939c827da65ff Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 13 May 2017 00:05:23 +0200 Subject: [PATCH] Fixed: Regression in Quality fallback by extension. --- .../ParserTests/ParserFixture.cs | 12 +++++++++++- src/NzbDrone.Core/Parser/Parser.cs | 14 +++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 2712c8dbf..5b214a0e6 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -1,6 +1,8 @@ +using System.Linq; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Parser; +using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.ParserTests @@ -47,7 +49,7 @@ public void should_parse_series_name(string postTitle, string title) public void should_remove_accents_from_title() { const string title = "Carniv\u00E0le"; - + title.CleanSeriesTitle().Should().Be("carnivale"); } @@ -62,5 +64,13 @@ public void should_remove_request_info_from_title(string postTitle, string title { Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title); } + + [TestCase("Revolution.S01E02.Chained.Heat.mkv")] + [TestCase("Dexter - S01E01 - Title.avi")] + public void should_parse_quality_from_extension(string title) + { + Parser.Parser.ParseTitle(title).Quality.Quality.Should().NotBe(Quality.Unknown); + Parser.Parser.ParseTitle(title).Quality.QualitySource.Should().Be(QualitySource.Extension); + } } } diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 814eb764f..36d54664b 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -316,9 +316,9 @@ public static ParsedEpisodeInfo ParseTitle(string title) Logger.Debug("Reversed name detected. Converted to '{0}'", title); } - title = RemoveFileExtension(title); + var releaseTitle = RemoveFileExtension(title); - var simpleTitle = SimpleTitleRegex.Replace(title, string.Empty); + var simpleTitle = SimpleTitleRegex.Replace(releaseTitle, string.Empty); // TODO: Quick fix stripping [url] - prefixes. simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty); @@ -365,13 +365,13 @@ public static ParsedEpisodeInfo ParseTitle(string title) result.Special = true; } - result.Language = LanguageParser.ParseLanguage(title); + result.Language = LanguageParser.ParseLanguage(releaseTitle); Logger.Debug("Language parsed: {0}", result.Language); result.Quality = QualityParser.ParseQuality(title); Logger.Debug("Quality parsed: {0}", result.Quality); - result.ReleaseGroup = ParseReleaseGroup(title); + result.ReleaseGroup = ParseReleaseGroup(releaseTitle); var subGroup = GetSubGroup(match); if (!subGroup.IsNullOrWhiteSpace()) @@ -522,7 +522,7 @@ private static SeriesTitleInfo GetSeriesTitleInfo(string title) return seriesTitleInfo; } - private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchCollection, string title) + private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchCollection, string releaseTitle) { var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' ').Replace('_', ' '); seriesName = RequestInfoRegex.Replace(seriesName, "").Trim(' '); @@ -551,7 +551,7 @@ private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchColle result = new ParsedEpisodeInfo { - ReleaseTitle = title, + ReleaseTitle = releaseTitle, SeasonNumber = seasons.First(), EpisodeNumbers = new int[0], AbsoluteEpisodeNumbers = new int[0] @@ -645,7 +645,7 @@ private static ParsedEpisodeInfo ParseMatchCollection(MatchCollection matchColle result = new ParsedEpisodeInfo { - ReleaseTitle = title, + ReleaseTitle = releaseTitle, AirDate = airDate.ToString(Episode.AIR_DATE_FORMAT), }; }