Fixed: Enable parsing of repacks with revision

Closes #5383
This commit is contained in:
Stevie Robinson 2023-02-04 09:08:35 +01:00 committed by GitHub
parent 83f6359063
commit e29470d8cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 21 deletions

View File

@ -466,14 +466,16 @@ namespace NzbDrone.Core.Test.ParserTests
result.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name); result.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name);
} }
[TestCase("Series Title S04E87 REPACK 720p HDTV x264 aAF", true)] [TestCase("Series Title S04E87 REPACK 720p HDTV x264 aAF", true, 2)]
[TestCase("Series.Title.S04E87.REPACK.720p.HDTV.x264-aAF", true)] [TestCase("Series.Title.S04E87.REPACK.720p.HDTV.x264-aAF", true, 2)]
[TestCase("Series.Title.S04E87.PROPER.720p.HDTV.x264-aAF", false)] [TestCase("Series.Title.S04E87.REPACK2.720p.HDTV.x264-aAF", true, 3)]
[TestCase("Series.Title.S01E07.RERIP.720p.BluRay.x264-DEMAND", true)] [TestCase("Series.Title.S04E87.PROPER.720p.HDTV.x264-aAF", false, 2)]
public void should_be_able_to_parse_repack(string title, bool isRepack) [TestCase("Series.Title.S01E07.RERIP.720p.BluRay.x264-DEMAND", true, 2)]
[TestCase("Series.Title.S01E07.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); var result = QualityParser.ParseQuality(title);
result.Revision.Version.Should().Be(2); result.Revision.Version.Should().Be(version);
result.Revision.IsRepack.Should().Be(isRepack); result.Revision.IsRepack.Should().Be(isRepack);
} }

View File

@ -37,10 +37,10 @@ namespace NzbDrone.Core.Parser
private static readonly Regex ProperRegex = new Regex(@"\b(?<proper>proper)\b", private static readonly Regex ProperRegex = new Regex(@"\b(?<proper>proper)\b",
RegexOptions.Compiled | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex RepackRegex = new Regex(@"\b(?<repack>repack|rerip)\b", private static readonly Regex RepackRegex = new Regex(@"\b(?<repack>repack\d?|rerip\d?)\b",
RegexOptions.Compiled | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex VersionRegex = new Regex(@"\d[-._ ]?v(?<version>\d)[-._ ]|\[v(?<version>\d)\]", private static readonly Regex VersionRegex = new Regex(@"\d[-._ ]?v(?<version>\d)[-._ ]|\[v(?<version>\d)\]|repack(?<version>\d)|rerip(?<version>\d)",
RegexOptions.Compiled | RegexOptions.IgnoreCase); RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex RealRegex = new Regex(@"\b(?<real>REAL)\b", private static readonly Regex RealRegex = new Regex(@"\b(?<real>REAL)\b",
@ -634,19 +634,6 @@ namespace NzbDrone.Core.Parser
{ {
var result = new QualityModel { Quality = Quality.Unknown }; var result = new QualityModel { Quality = Quality.Unknown };
if (ProperRegex.IsMatch(normalizedName))
{
result.Revision.Version = 2;
result.RevisionDetectionSource = QualityDetectionSource.Name;
}
if (RepackRegex.IsMatch(normalizedName))
{
result.Revision.Version = 2;
result.Revision.IsRepack = true;
result.RevisionDetectionSource = QualityDetectionSource.Name;
}
var versionRegexResult = VersionRegex.Match(normalizedName); var versionRegexResult = VersionRegex.Match(normalizedName);
if (versionRegexResult.Success) if (versionRegexResult.Success)
@ -655,6 +642,19 @@ namespace NzbDrone.Core.Parser
result.RevisionDetectionSource = QualityDetectionSource.Name; result.RevisionDetectionSource = QualityDetectionSource.Name;
} }
if (ProperRegex.IsMatch(normalizedName))
{
result.Revision.Version = versionRegexResult.Success ? Convert.ToInt32(versionRegexResult.Groups["version"].Value) + 1 : 2;
result.RevisionDetectionSource = QualityDetectionSource.Name;
}
if (RepackRegex.IsMatch(normalizedName))
{
result.Revision.Version = versionRegexResult.Success ? Convert.ToInt32(versionRegexResult.Groups["version"].Value) + 1 : 2;
result.Revision.IsRepack = true;
result.RevisionDetectionSource = QualityDetectionSource.Name;
}
// TODO: re-enable this when we have a reliable way to determine real // TODO: re-enable this when we have a reliable way to determine real
// TODO: Only treat it as a real if it comes AFTER the season/episode number // TODO: Only treat it as a real if it comes AFTER the season/episode number
var realRegexResult = RealRegex.Matches(name); var realRegexResult = RealRegex.Matches(name);