mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Fixed: Use Modifier in Quality Aggregation
This commit is contained in:
parent
5fe8884471
commit
78cac9fcfa
@ -32,10 +32,10 @@ public void Setup()
|
||||
.Returns(AugmentQualityResult.ResolutionOnly(Resolution.R1080P, Confidence.MediaInfo));
|
||||
|
||||
_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>()))
|
||||
.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)
|
||||
|
@ -30,6 +30,8 @@ public LocalMovie Aggregate(LocalMovie localMovie, bool otherFiles)
|
||||
var sourceConfidence = Confidence.Default;
|
||||
var resolution = Resolution.Unknown;
|
||||
var resolutionConfidence = Confidence.Default;
|
||||
var modifier = Modifier.NONE;
|
||||
var modifierConfidence = Confidence.Default;
|
||||
var revison = new Revision();
|
||||
|
||||
foreach (var augmentedQuality in augmentedQualities)
|
||||
@ -48,6 +50,13 @@ public LocalMovie Aggregate(LocalMovie localMovie, bool otherFiles)
|
||||
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)
|
||||
{
|
||||
revison = augmentedQuality.Revision;
|
||||
@ -56,7 +65,7 @@ public LocalMovie Aggregate(LocalMovie localMovie, bool otherFiles)
|
||||
|
||||
_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)
|
||||
{
|
||||
|
@ -17,6 +17,8 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie)
|
||||
Confidence.Tag,
|
||||
quality.Quality.Resolution,
|
||||
Confidence.Tag,
|
||||
quality.Quality.Modifier,
|
||||
Confidence.Tag,
|
||||
quality.Revision);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie)
|
||||
confidence,
|
||||
quality.Quality.Resolution,
|
||||
confidence,
|
||||
quality.Quality.Modifier,
|
||||
confidence,
|
||||
quality.Revision);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ public AugmentQualityResult AugmentQuality(LocalMovie localMovie)
|
||||
Confidence.Tag,
|
||||
quality.Quality.Resolution,
|
||||
Confidence.Tag,
|
||||
quality.Quality.Modifier,
|
||||
Confidence.Tag,
|
||||
quality.Revision);
|
||||
}
|
||||
}
|
||||
|
@ -9,29 +9,40 @@ public class AugmentQualityResult
|
||||
public Confidence SourceConfidence { get; set; }
|
||||
public Resolution Resolution { get; set; }
|
||||
public Confidence ResolutionConfidence { get; set; }
|
||||
public Modifier Modifier { get; set; }
|
||||
public Confidence ModifierConfidence { get; set; }
|
||||
public Revision Revision { get; set; }
|
||||
|
||||
public AugmentQualityResult(Source source,
|
||||
Confidence sourceConfidence,
|
||||
Resolution resolution,
|
||||
Confidence resolutionConfidence,
|
||||
Modifier modifier,
|
||||
Confidence modifierConfidence,
|
||||
Revision revision)
|
||||
{
|
||||
Source = source;
|
||||
SourceConfidence = sourceConfidence;
|
||||
Resolution = resolution;
|
||||
ResolutionConfidence = resolutionConfidence;
|
||||
Modifier = modifier;
|
||||
ModifierConfidence = modifierConfidence;
|
||||
Revision = revision;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ private ParsedMovieInfo EnhanceMinimalInfo(ParsedMovieInfo minimalInfo, List<obj
|
||||
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.CustomFormats = ParseCustomFormat(minimalInfo);
|
||||
|
@ -213,16 +213,5 @@ public static explicit operator int(Quality quality)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ public static class 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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user