mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Fixed: Correctly storing v0 version during import, allowing them to be upgraded to v1 later
Fixes #5305 Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
d7938b6282
commit
bb5f5eeee6
@ -37,10 +37,10 @@ public void Setup()
|
|||||||
_mediaInfoAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>())).Returns(AugmentQualityResult.ResolutionOnly((int)Resolution.R1080p, Confidence.MediaInfo));
|
_mediaInfoAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>())).Returns(AugmentQualityResult.ResolutionOnly((int)Resolution.R1080p, Confidence.MediaInfo));
|
||||||
|
|
||||||
_fileExtensionAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
_fileExtensionAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new AugmentQualityResult(Source.TV, Confidence.Fallback, (int)Resolution.R720p, Confidence.Fallback, Modifier.NONE, Confidence.Fallback, new Revision()));
|
.Returns(new AugmentQualityResult(Source.TV, Confidence.Fallback, (int)Resolution.R720p, Confidence.Fallback, Modifier.NONE, Confidence.Fallback, new Revision(), Confidence.Fallback));
|
||||||
|
|
||||||
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, 480, Confidence.Default, Modifier.NONE, Confidence.Fallback, new Revision()));
|
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, 480, Confidence.Default, Modifier.NONE, Confidence.Fallback, new Revision(), Confidence.Default));
|
||||||
|
|
||||||
_releaseNameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
_releaseNameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(AugmentQualityResult.SourceOnly(Source.WEBDL, Confidence.MediaInfo));
|
.Returns(AugmentQualityResult.SourceOnly(Source.WEBDL, Confidence.MediaInfo));
|
||||||
@ -114,5 +114,61 @@ public void should_return_WEBDL480p_when_file_name_has_HDTV480p_but_release_name
|
|||||||
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name);
|
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.Name);
|
||||||
result.Quality.Quality.Should().Be(Quality.WEBDL480p);
|
result.Quality.Quality.Should().Be(Quality.WEBDL480p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_version_1_when_no_version_specified()
|
||||||
|
{
|
||||||
|
GivenAugmenters(_nameAugmenter, _releaseNameAugmenter);
|
||||||
|
|
||||||
|
var result = Subject.Aggregate(new LocalMovie(), new DownloadClientItem(), false);
|
||||||
|
|
||||||
|
result.Quality.Revision.Version.Should().Be(1);
|
||||||
|
result.Quality.RevisionDetectionSource.Should().Be(QualityDetectionSource.Unknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_version_2_when_name_indicates_proper()
|
||||||
|
{
|
||||||
|
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
|
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, 480, Confidence.Default, Modifier.NONE, Confidence.Default, new Revision(2), Confidence.Tag));
|
||||||
|
|
||||||
|
GivenAugmenters(_nameAugmenter, _releaseNameAugmenter);
|
||||||
|
|
||||||
|
var result = Subject.Aggregate(new LocalMovie(), new DownloadClientItem(), false);
|
||||||
|
|
||||||
|
result.Quality.Revision.Version.Should().Be(2);
|
||||||
|
result.Quality.RevisionDetectionSource.Should().Be(QualityDetectionSource.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_version_0_when_file_name_indicates_v0()
|
||||||
|
{
|
||||||
|
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
|
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, 480, Confidence.Default, Modifier.NONE, Confidence.Default, new Revision(0), Confidence.Tag));
|
||||||
|
|
||||||
|
GivenAugmenters(_nameAugmenter, _releaseNameAugmenter);
|
||||||
|
|
||||||
|
var result = Subject.Aggregate(new LocalMovie(), new DownloadClientItem(), false);
|
||||||
|
|
||||||
|
result.Quality.Revision.Version.Should().Be(0);
|
||||||
|
result.Quality.RevisionDetectionSource.Should().Be(QualityDetectionSource.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_version_2_when_file_name_indicates_v0_and_release_name_indicates_v2()
|
||||||
|
{
|
||||||
|
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
|
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, 480, Confidence.Default, Modifier.NONE, Confidence.Default, new Revision(0), Confidence.Tag));
|
||||||
|
|
||||||
|
_releaseNameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>(), It.IsAny<DownloadClientItem>()))
|
||||||
|
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, 480, Confidence.Default, Modifier.NONE, Confidence.Default, new Revision(2), Confidence.Tag));
|
||||||
|
|
||||||
|
GivenAugmenters(_nameAugmenter, _releaseNameAugmenter);
|
||||||
|
|
||||||
|
var result = Subject.Aggregate(new LocalMovie(), new DownloadClientItem(), false);
|
||||||
|
|
||||||
|
result.Quality.Revision.Version.Should().Be(2);
|
||||||
|
result.Quality.RevisionDetectionSource.Should().Be(QualityDetectionSource.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@ public LocalMovie Aggregate(LocalMovie localMovie, DownloadClientItem downloadCl
|
|||||||
var resolutionConfidence = Confidence.Default;
|
var resolutionConfidence = Confidence.Default;
|
||||||
var modifier = Modifier.NONE;
|
var modifier = Modifier.NONE;
|
||||||
var modifierConfidence = Confidence.Default;
|
var modifierConfidence = Confidence.Default;
|
||||||
var revision = new Revision();
|
var revision = new Revision(1);
|
||||||
|
var revisionConfidence = Confidence.Default;
|
||||||
|
|
||||||
foreach (var augmentQuality in _augmentQualities)
|
foreach (var augmentQuality in _augmentQualities)
|
||||||
{
|
{
|
||||||
@ -61,9 +62,24 @@ public LocalMovie Aggregate(LocalMovie localMovie, DownloadClientItem downloadCl
|
|||||||
modifierConfidence = augmentedQuality.ModifierConfidence;
|
modifierConfidence = augmentedQuality.ModifierConfidence;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (augmentedQuality.Revision != null && augmentedQuality.Revision > revision)
|
if (augmentedQuality.Revision != null)
|
||||||
{
|
{
|
||||||
revision = augmentedQuality.Revision;
|
// Update the revision and confidence if it is higher than the current confidence,
|
||||||
|
// this will allow explicitly detected v0 to override the v1 default.
|
||||||
|
if (augmentedQuality.RevisionConfidence > revisionConfidence)
|
||||||
|
{
|
||||||
|
revision = augmentedQuality.Revision;
|
||||||
|
revisionConfidence = augmentedQuality.RevisionConfidence;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the revision and confidence if it is the same confidence and the revision is higher,
|
||||||
|
// this will allow the best revision to be used in the event there is a disagreement.
|
||||||
|
else if (augmentedQuality.RevisionConfidence == revisionConfidence &&
|
||||||
|
augmentedQuality.Revision > revision)
|
||||||
|
{
|
||||||
|
revision = augmentedQuality.Revision;
|
||||||
|
revisionConfidence = augmentedQuality.RevisionConfidence;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +109,8 @@ public LocalMovie Aggregate(LocalMovie localMovie, DownloadClientItem downloadCl
|
|||||||
quality.SourceDetectionSource = QualityDetectionSource.Name;
|
quality.SourceDetectionSource = QualityDetectionSource.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quality.RevisionDetectionSource = revisionConfidence == Confidence.Tag ? QualityDetectionSource.Name : QualityDetectionSource.Unknown;
|
||||||
|
|
||||||
_logger.Debug("Using quality: {0}", quality);
|
_logger.Debug("Using quality: {0}", quality);
|
||||||
|
|
||||||
localMovie.Quality = quality;
|
localMovie.Quality = quality;
|
||||||
|
@ -30,13 +30,18 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie, DownloadClient
|
|||||||
? Confidence.Tag
|
? Confidence.Tag
|
||||||
: Confidence.Fallback;
|
: Confidence.Fallback;
|
||||||
|
|
||||||
|
var revisionConfidence = quality.RevisionDetectionSource == QualityDetectionSource.Name
|
||||||
|
? Confidence.Tag
|
||||||
|
: Confidence.Fallback;
|
||||||
|
|
||||||
return new AugmentQualityResult(quality.Quality.Source,
|
return new AugmentQualityResult(quality.Quality.Source,
|
||||||
sourceConfidence,
|
sourceConfidence,
|
||||||
quality.Quality.Resolution,
|
quality.Quality.Resolution,
|
||||||
resolutionConfidence,
|
resolutionConfidence,
|
||||||
quality.Quality.Modifier,
|
quality.Quality.Modifier,
|
||||||
modifierConfidence,
|
modifierConfidence,
|
||||||
quality.Revision);
|
quality.Revision,
|
||||||
|
revisionConfidence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,18 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie, DownloadClient
|
|||||||
? Confidence.Tag
|
? Confidence.Tag
|
||||||
: Confidence.Fallback;
|
: Confidence.Fallback;
|
||||||
|
|
||||||
|
var revisionConfidence = quality.RevisionDetectionSource == QualityDetectionSource.Name
|
||||||
|
? Confidence.Tag
|
||||||
|
: Confidence.Fallback;
|
||||||
|
|
||||||
return new AugmentQualityResult(quality.Quality.Source,
|
return new AugmentQualityResult(quality.Quality.Source,
|
||||||
sourceConfidence,
|
sourceConfidence,
|
||||||
quality.Quality.Resolution,
|
quality.Quality.Resolution,
|
||||||
resolutionConfidence,
|
resolutionConfidence,
|
||||||
quality.Quality.Modifier,
|
quality.Quality.Modifier,
|
||||||
modifierConfidence,
|
modifierConfidence,
|
||||||
quality.Revision);
|
quality.Revision,
|
||||||
|
revisionConfidence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,18 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie, DownloadClient
|
|||||||
? Confidence.Tag
|
? Confidence.Tag
|
||||||
: Confidence.Fallback;
|
: Confidence.Fallback;
|
||||||
|
|
||||||
|
var revisionConfidence = quality.RevisionDetectionSource == QualityDetectionSource.Name
|
||||||
|
? Confidence.Tag
|
||||||
|
: Confidence.Fallback;
|
||||||
|
|
||||||
return new AugmentQualityResult(quality.Quality.Source,
|
return new AugmentQualityResult(quality.Quality.Source,
|
||||||
sourceConfidence,
|
sourceConfidence,
|
||||||
quality.Quality.Resolution,
|
quality.Quality.Resolution,
|
||||||
resolutionConfidence,
|
resolutionConfidence,
|
||||||
quality.Quality.Modifier,
|
quality.Quality.Modifier,
|
||||||
modifierConfidence,
|
modifierConfidence,
|
||||||
quality.Revision);
|
quality.Revision,
|
||||||
|
revisionConfidence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,17 +33,24 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie, DownloadClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
var historyQuality = QualityParser.ParseQuality(history.SourceTitle);
|
var historyQuality = QualityParser.ParseQuality(history.SourceTitle);
|
||||||
|
|
||||||
var sourceConfidence = historyQuality.SourceDetectionSource == QualityDetectionSource.Name
|
var sourceConfidence = historyQuality.SourceDetectionSource == QualityDetectionSource.Name
|
||||||
? Confidence.Tag
|
? Confidence.Tag
|
||||||
: Confidence.Fallback;
|
: Confidence.Fallback;
|
||||||
|
|
||||||
var resolutionConfidence = historyQuality.ResolutionDetectionSource == QualityDetectionSource.Name
|
var resolutionConfidence = historyQuality.ResolutionDetectionSource == QualityDetectionSource.Name
|
||||||
? Confidence.Tag
|
? Confidence.Tag
|
||||||
: Confidence.Fallback;
|
: Confidence.Fallback;
|
||||||
|
|
||||||
var modifierConfidence = historyQuality.ModifierDetectionSource == QualityDetectionSource.Name
|
var modifierConfidence = historyQuality.ModifierDetectionSource == QualityDetectionSource.Name
|
||||||
? Confidence.Tag
|
? Confidence.Tag
|
||||||
: Confidence.Fallback;
|
: Confidence.Fallback;
|
||||||
|
|
||||||
return new AugmentQualityResult(historyQuality.Quality.Source, sourceConfidence, historyQuality.Quality.Resolution, resolutionConfidence, historyQuality.Quality.Modifier, modifierConfidence, historyQuality.Revision);
|
var revisionConfidence = historyQuality.RevisionDetectionSource == QualityDetectionSource.Name
|
||||||
|
? Confidence.Tag
|
||||||
|
: Confidence.Fallback;
|
||||||
|
|
||||||
|
return new AugmentQualityResult(historyQuality.Quality.Source, sourceConfidence, historyQuality.Quality.Resolution, resolutionConfidence, historyQuality.Quality.Modifier, modifierConfidence, historyQuality.Revision, revisionConfidence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ public class AugmentQualityResult
|
|||||||
public Modifier Modifier { get; set; }
|
public Modifier Modifier { get; set; }
|
||||||
public Confidence ModifierConfidence { get; set; }
|
public Confidence ModifierConfidence { get; set; }
|
||||||
public Revision Revision { get; set; }
|
public Revision Revision { get; set; }
|
||||||
|
public Confidence RevisionConfidence { get; set; }
|
||||||
|
|
||||||
public AugmentQualityResult(Source source,
|
public AugmentQualityResult(Source source,
|
||||||
Confidence sourceConfidence,
|
Confidence sourceConfidence,
|
||||||
@ -19,7 +20,8 @@ public AugmentQualityResult(Source source,
|
|||||||
Confidence resolutionConfidence,
|
Confidence resolutionConfidence,
|
||||||
Modifier modifier,
|
Modifier modifier,
|
||||||
Confidence modifierConfidence,
|
Confidence modifierConfidence,
|
||||||
Revision revision)
|
Revision revision,
|
||||||
|
Confidence revisionConfidence)
|
||||||
{
|
{
|
||||||
Source = source;
|
Source = source;
|
||||||
SourceConfidence = sourceConfidence;
|
SourceConfidence = sourceConfidence;
|
||||||
@ -28,21 +30,22 @@ public AugmentQualityResult(Source source,
|
|||||||
Modifier = modifier;
|
Modifier = modifier;
|
||||||
ModifierConfidence = modifierConfidence;
|
ModifierConfidence = modifierConfidence;
|
||||||
Revision = revision;
|
Revision = revision;
|
||||||
|
RevisionConfidence = revisionConfidence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AugmentQualityResult SourceOnly(Source source, Confidence sourceConfidence)
|
public static AugmentQualityResult SourceOnly(Source source, Confidence sourceConfidence)
|
||||||
{
|
{
|
||||||
return new AugmentQualityResult(source, sourceConfidence, 0, Confidence.Default, Modifier.NONE, Confidence.Default, null);
|
return new AugmentQualityResult(source, sourceConfidence, 0, Confidence.Default, Modifier.NONE, Confidence.Default, null, Confidence.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AugmentQualityResult ResolutionOnly(int resolution, Confidence resolutionConfidence)
|
public static AugmentQualityResult ResolutionOnly(int resolution, Confidence resolutionConfidence)
|
||||||
{
|
{
|
||||||
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, resolution, resolutionConfidence, Modifier.NONE, Confidence.Default, null);
|
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, resolution, resolutionConfidence, Modifier.NONE, Confidence.Default, null, Confidence.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AugmentQualityResult ModifierOnly(Modifier modifier, Confidence modifierConfidence)
|
public static AugmentQualityResult ModifierOnly(Modifier modifier, Confidence modifierConfidence)
|
||||||
{
|
{
|
||||||
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, 0, Confidence.Default, modifier, modifierConfidence, null);
|
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, 0, Confidence.Default, modifier, modifierConfidence, null, Confidence.Default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,12 +666,14 @@ private static QualityModel ParseQualityModifiers(string name, string normalized
|
|||||||
if (ProperRegex.IsMatch(normalizedName))
|
if (ProperRegex.IsMatch(normalizedName))
|
||||||
{
|
{
|
||||||
result.Revision.Version = 2;
|
result.Revision.Version = 2;
|
||||||
|
result.RevisionDetectionSource = QualityDetectionSource.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RepackRegex.IsMatch(normalizedName))
|
if (RepackRegex.IsMatch(normalizedName))
|
||||||
{
|
{
|
||||||
result.Revision.Version = 2;
|
result.Revision.Version = 2;
|
||||||
result.Revision.IsRepack = true;
|
result.Revision.IsRepack = true;
|
||||||
|
result.RevisionDetectionSource = QualityDetectionSource.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
var versionRegexResult = VersionRegex.Match(normalizedName);
|
var versionRegexResult = VersionRegex.Match(normalizedName);
|
||||||
@ -679,6 +681,7 @@ private static QualityModel ParseQualityModifiers(string name, string normalized
|
|||||||
if (versionRegexResult.Success)
|
if (versionRegexResult.Success)
|
||||||
{
|
{
|
||||||
result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value);
|
result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value);
|
||||||
|
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
|
||||||
@ -688,6 +691,7 @@ private static QualityModel ParseQualityModifiers(string name, string normalized
|
|||||||
if (realRegexResult.Count > 0)
|
if (realRegexResult.Count > 0)
|
||||||
{
|
{
|
||||||
result.Revision.Real = realRegexResult.Count;
|
result.Revision.Real = realRegexResult.Count;
|
||||||
|
result.RevisionDetectionSource = QualityDetectionSource.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -21,6 +21,9 @@ public class QualityModel : IEmbeddedDocument, IEquatable<QualityModel>
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public QualityDetectionSource ModifierDetectionSource { get; set; }
|
public QualityDetectionSource ModifierDetectionSource { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public QualityDetectionSource RevisionDetectionSource { get; set; }
|
||||||
|
|
||||||
public QualityModel()
|
public QualityModel()
|
||||||
: this(Quality.Unknown, new Revision())
|
: this(Quality.Unknown, new Revision())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user