1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Use Modifier in Quality Aggregation

This commit is contained in:
Qstick 2019-09-23 22:10:51 -04:00
parent 5fe8884471
commit 78cac9fcfa
9 changed files with 34 additions and 19 deletions

View File

@ -32,10 +32,10 @@ public void Setup()
.Returns(AugmentQualityResult.ResolutionOnly(Resolution.R1080P, Confidence.MediaInfo)); .Returns(AugmentQualityResult.ResolutionOnly(Resolution.R1080P, Confidence.MediaInfo));
_fileExtensionAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>())) _fileExtensionAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>()))
.Returns(new AugmentQualityResult(Source.TV, Confidence.Fallback, Resolution.R720P, Confidence.Fallback, new Revision())); .Returns(new AugmentQualityResult(Source.TV, Confidence.Fallback, Resolution.R720P, Confidence.Fallback, Modifier.NONE, Confidence.Fallback, new Revision()));
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>())) _nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalMovie>()))
.Returns(new AugmentQualityResult(Source.TV, Confidence.Default, Resolution.R480P, Confidence.Default, new Revision())); .Returns(new AugmentQualityResult(Source.TV, Confidence.Default, Resolution.R480P, Confidence.Default, Modifier.NONE, Confidence.Default, new Revision()));
} }
private void GivenAugmenters(params Mock<IAugmentQuality>[] mocks) private void GivenAugmenters(params Mock<IAugmentQuality>[] mocks)

View File

@ -30,6 +30,8 @@ public LocalMovie Aggregate(LocalMovie localMovie, bool otherFiles)
var sourceConfidence = Confidence.Default; var sourceConfidence = Confidence.Default;
var resolution = Resolution.Unknown; var resolution = Resolution.Unknown;
var resolutionConfidence = Confidence.Default; var resolutionConfidence = Confidence.Default;
var modifier = Modifier.NONE;
var modifierConfidence = Confidence.Default;
var revison = new Revision(); var revison = new Revision();
foreach (var augmentedQuality in augmentedQualities) foreach (var augmentedQuality in augmentedQualities)
@ -48,6 +50,13 @@ public LocalMovie Aggregate(LocalMovie localMovie, bool otherFiles)
resolutionConfidence = augmentedQuality.ResolutionConfidence; resolutionConfidence = augmentedQuality.ResolutionConfidence;
} }
if (augmentedQuality.Modifier > modifier ||
augmentedQuality.ModifierConfidence > modifierConfidence && augmentedQuality.Modifier != Modifier.NONE)
{
modifier = augmentedQuality.Modifier;
modifierConfidence = augmentedQuality.ModifierConfidence;
}
if (augmentedQuality.Revision != null && augmentedQuality.Revision > revison) if (augmentedQuality.Revision != null && augmentedQuality.Revision > revison)
{ {
revison = augmentedQuality.Revision; revison = augmentedQuality.Revision;
@ -56,7 +65,7 @@ public LocalMovie Aggregate(LocalMovie localMovie, bool otherFiles)
_logger.Trace("Finding quality. Source: {0}. Resolution: {1}", source, resolution); _logger.Trace("Finding quality. Source: {0}. Resolution: {1}", source, resolution);
var quality = new QualityModel(QualityFinder.FindBySourceAndResolution(source, resolution), revison); var quality = new QualityModel(QualityFinder.FindBySourceAndResolution(source, resolution, modifier), revison);
if (resolutionConfidence == Confidence.MediaInfo) if (resolutionConfidence == Confidence.MediaInfo)
{ {

View File

@ -17,6 +17,8 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie)
Confidence.Tag, Confidence.Tag,
quality.Quality.Resolution, quality.Quality.Resolution,
Confidence.Tag, Confidence.Tag,
quality.Quality.Modifier,
Confidence.Tag,
quality.Revision); quality.Revision);
} }
} }

View File

@ -22,6 +22,8 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie)
confidence, confidence,
quality.Quality.Resolution, quality.Quality.Resolution,
confidence, confidence,
quality.Quality.Modifier,
confidence,
quality.Revision); quality.Revision);
} }
} }

View File

@ -17,6 +17,8 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie)
Confidence.Tag, Confidence.Tag,
quality.Quality.Resolution, quality.Quality.Resolution,
Confidence.Tag, Confidence.Tag,
quality.Quality.Modifier,
Confidence.Tag,
quality.Revision); quality.Revision);
} }
} }

View File

@ -9,29 +9,40 @@ public class AugmentQualityResult
public Confidence SourceConfidence { get; set; } public Confidence SourceConfidence { get; set; }
public Resolution Resolution { get; set; } public Resolution Resolution { get; set; }
public Confidence ResolutionConfidence { get; set; } public Confidence ResolutionConfidence { get; set; }
public Modifier Modifier { get; set; }
public Confidence ModifierConfidence { get; set; }
public Revision Revision { get; set; } public Revision Revision { get; set; }
public AugmentQualityResult(Source source, public AugmentQualityResult(Source source,
Confidence sourceConfidence, Confidence sourceConfidence,
Resolution resolution, Resolution resolution,
Confidence resolutionConfidence, Confidence resolutionConfidence,
Modifier modifier,
Confidence modifierConfidence,
Revision revision) Revision revision)
{ {
Source = source; Source = source;
SourceConfidence = sourceConfidence; SourceConfidence = sourceConfidence;
Resolution = resolution; Resolution = resolution;
ResolutionConfidence = resolutionConfidence; ResolutionConfidence = resolutionConfidence;
Modifier = modifier;
ModifierConfidence = modifierConfidence;
Revision = revision; Revision = revision;
} }
public static AugmentQualityResult SourceOnly(Source source, Confidence sourceConfidence) public static AugmentQualityResult SourceOnly(Source source, Confidence sourceConfidence)
{ {
return new AugmentQualityResult(source, sourceConfidence, 0, Confidence.Default, null); return new AugmentQualityResult(source, sourceConfidence, 0, Confidence.Default, Modifier.NONE, Confidence.Default, null);
} }
public static AugmentQualityResult ResolutionOnly(Resolution resolution, Confidence resolutionConfidence) public static AugmentQualityResult ResolutionOnly(Resolution resolution, Confidence resolutionConfidence)
{ {
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, resolution, resolutionConfidence, null); return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, resolution, resolutionConfidence, Modifier.NONE, Confidence.Default, null);
}
public static AugmentQualityResult ModifierOnly(Modifier modifier, Confidence modifierConfidence)
{
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, 0, Confidence.Default, modifier, modifierConfidence, null);
} }
} }
} }

View File

@ -97,7 +97,7 @@ private ParsedMovieInfo EnhanceMinimalInfo(ParsedMovieInfo minimalInfo, List<obj
minimalInfo.Languages = minimalInfo.Languages =
LanguageParser.EnhanceLanguages(minimalInfo.SimpleReleaseTitle, minimalInfo.Languages); LanguageParser.EnhanceLanguages(minimalInfo.SimpleReleaseTitle, minimalInfo.Languages);
minimalInfo.Quality.Quality = Quality.FindByInfo(minimalInfo.Quality.Source, minimalInfo.Quality.Resolution, minimalInfo.Quality.Quality = QualityFinder.FindBySourceAndResolution(minimalInfo.Quality.Source, minimalInfo.Quality.Resolution,
minimalInfo.Quality.Modifier); minimalInfo.Quality.Modifier);
minimalInfo.Quality.CustomFormats = ParseCustomFormat(minimalInfo); minimalInfo.Quality.CustomFormats = ParseCustomFormat(minimalInfo);

View File

@ -213,16 +213,5 @@ public static explicit operator int(Quality quality)
{ {
return quality.Id; return quality.Id;
} }
//TODO: Go back to fully parsing the quality from the start!
public static Quality FindByInfo(Source source, Resolution resolution, Modifier modifier)
{
return All.SingleOrDefault(q =>
q.Source == source && ((q.Resolution == resolution) ||
(q.Resolution == Resolution.Unknown)) && (q.Modifier == modifier)) ??
All.FirstOrDefault(q => q.Source == source && ((q.Resolution == resolution) ||
(q.Resolution == Resolution.Unknown))) ??
Unknown;
}
} }
} }

View File

@ -9,9 +9,9 @@ public static class QualityFinder
{ {
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(QualityFinder)); private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(QualityFinder));
public static Quality FindBySourceAndResolution(Source source, Resolution resolution) public static Quality FindBySourceAndResolution(Source source, Resolution resolution, Modifier modifer)
{ {
var matchingQuality = Quality.All.SingleOrDefault(q => q.Source == source && q.Resolution == resolution); var matchingQuality = Quality.All.SingleOrDefault(q => q.Source == source && q.Resolution == resolution && q.Modifier == modifer);
if (matchingQuality != null) if (matchingQuality != null)
{ {