diff --git a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs index d3c150d02..de6245e2e 100644 --- a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs @@ -453,14 +453,16 @@ namespace NzbDrone.Core.Test.ParserTests result.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name); } - [TestCase("Movie Title 2018 REPACK 720p x264 aAF", true)] - [TestCase("Movie.Title.2018.REPACK.720p.x264-aAF", true)] - [TestCase("Movie.Title.2018.PROPER.720p.x264-aAF", false)] - [TestCase("Movie.Title.2018.RERIP.720p.BluRay.x264-DEMAND", true)] - public void should_be_able_to_parse_repack(string title, bool isRepack) + [TestCase("Movie Title 2018 REPACK 720p HDTV x264 aAF", true, 2)] + [TestCase("Movie.Title.2018.REPACK.720p.HDTV.x264-aAF", true, 2)] + [TestCase("Movie.Title.2018.REPACK2.720p.HDTV.x264-aAF", true, 3)] + [TestCase("Movie.Title.2018.PROPER.720p.HDTV.x264-aAF", false, 2)] + [TestCase("Movie.Title.2018.RERIP.720p.BluRay.x264-DEMAND", true, 2)] + [TestCase("Movie.Title.2018.RERIP2.720p.BluRay.x264-DEMAND", true, 3)] + public void should_be_able_to_parse_repack(string title, bool isRepack, int version) { var result = QualityParser.ParseQuality(title); - result.Revision.Version.Should().Be(2); + result.Revision.Version.Should().Be(version); result.Revision.IsRepack.Should().Be(isRepack); } diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index ad0e2537e..4cc2b8917 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -47,11 +47,11 @@ namespace NzbDrone.Core.Parser private static readonly Regex ProperRegex = new (@"\b(?proper)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex RepackRegex = new (@"\b(?repack|rerip)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex RepackRegex = new (@"\b(?repack\d?|rerip\d?)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex VersionRegex = new (@"\d[-._ ]?v(?\d)[-._ ]|\[v(?\d)\]", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex VersionRegex = new (@"\d[-._ ]?v(?\d)[-._ ]|\[v(?\d)\]|repack(?\d)|rerip(?\d)", + RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex RealRegex = new (@"\b(?REAL)\b", RegexOptions.Compiled); @@ -706,24 +706,24 @@ namespace NzbDrone.Core.Parser { var result = new QualityModel { Quality = Quality.Unknown }; - if (ProperRegex.IsMatch(normalizedName)) + var versionRegexResult = VersionRegex.Match(normalizedName); + + if (versionRegexResult.Success) { - result.Revision.Version = 2; + result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value); result.RevisionDetectionSource = QualityDetectionSource.Name; } - if (RepackRegex.IsMatch(normalizedName)) + if (ProperRegex.IsMatch(normalizedName)) { - result.Revision.Version = 2; - result.Revision.IsRepack = true; + result.Revision.Version = versionRegexResult.Success ? Convert.ToInt32(versionRegexResult.Groups["version"].Value) + 1 : 2; result.RevisionDetectionSource = QualityDetectionSource.Name; } - var versionRegexResult = VersionRegex.Match(normalizedName); - - if (versionRegexResult.Success) + if (RepackRegex.IsMatch(normalizedName)) { - result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value); + result.Revision.Version = versionRegexResult.Success ? Convert.ToInt32(versionRegexResult.Groups["version"].Value) + 1 : 2; + result.Revision.IsRepack = true; result.RevisionDetectionSource = QualityDetectionSource.Name; }