mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Fixed: Enable parsing of repacks with revision
Closes #3320 (cherry picked from commit e29470d8cb9dd3d4d75a3abe1b9b7e8df4f2df4a)
This commit is contained in:
parent
5107fe73a1
commit
3d7d43bb46
3 changed files with 28 additions and 18 deletions
|
@ -307,13 +307,16 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
QualityParser.ParseCodec(null, null).Should().Be(Codec.Unknown);
|
||||
}
|
||||
|
||||
[TestCase("Artist Title - Album Title 2017 REPACK FLAC aAF", true)]
|
||||
[TestCase("Artist Title - Album Title 2017 RERIP FLAC aAF", true)]
|
||||
[TestCase("Artist Title - Album Title 2017 PROPER FLAC aAF", false)]
|
||||
public void should_be_able_to_parse_repack(string title, bool isRepack)
|
||||
[TestCase("Artist Title - Album Title 2017 REPACK FLAC aAF", true, 2)]
|
||||
[TestCase("Artist.Title-Album.Title.2017.REPACK.FLAC-aAF", true, 2)]
|
||||
[TestCase("Artist.Title-Album.Title.2017.REPACK2.FLAC-aAF", true, 3)]
|
||||
[TestCase("Artist Title - Album Title 2017 RERIP FLAC aAF", true, 2)]
|
||||
[TestCase("Artist Title - Album Title 2017 RERIP2 FLAC aAF", true, 3)]
|
||||
[TestCase("Artist Title - Album Title 2017 PROPER FLAC aAF", false, 2)]
|
||||
public void should_be_able_to_parse_repack(string title, bool isRepack, int version)
|
||||
{
|
||||
var result = QualityParser.ParseQuality(title, null, 0);
|
||||
result.Revision.Version.Should().Be(2);
|
||||
result.Revision.Version.Should().Be(version);
|
||||
result.Revision.IsRepack.Should().Be(isRepack);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ namespace NzbDrone.Core.Parser
|
|||
private static readonly Regex ProperRegex = new Regex(@"\b(?<proper>proper)\b",
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
private static readonly Regex RealRegex = new Regex(@"\b(?<real>REAL)\b",
|
||||
|
@ -616,22 +616,25 @@ namespace NzbDrone.Core.Parser
|
|||
{
|
||||
var result = new QualityModel { Quality = Quality.Unknown };
|
||||
|
||||
if (ProperRegex.IsMatch(normalizedName))
|
||||
{
|
||||
result.Revision.Version = 2;
|
||||
}
|
||||
|
||||
if (RepackRegex.IsMatch(normalizedName))
|
||||
{
|
||||
result.Revision.Version = 2;
|
||||
result.Revision.IsRepack = true;
|
||||
}
|
||||
|
||||
var versionRegexResult = VersionRegex.Match(normalizedName);
|
||||
|
||||
if (versionRegexResult.Success)
|
||||
{
|
||||
result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value);
|
||||
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
|
||||
|
@ -640,6 +643,7 @@ namespace NzbDrone.Core.Parser
|
|||
if (realRegexResult.Count > 0)
|
||||
{
|
||||
result.Revision.Real = realRegexResult.Count;
|
||||
result.RevisionDetectionSource = QualityDetectionSource.Name;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -13,6 +13,9 @@ namespace NzbDrone.Core.Qualities
|
|||
[JsonIgnore]
|
||||
public QualityDetectionSource QualityDetectionSource { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public QualityDetectionSource RevisionDetectionSource { get; set; }
|
||||
|
||||
public QualityModel()
|
||||
: this(Quality.Unknown, new Revision())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue