mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-27 04:21:27 +02:00
Fixed: Use Modifier in Quality Aggregation
This commit is contained in:
@@ -32,10 +32,10 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Aggregation.Aggregators
|
|||||||
.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)
|
||||||
|
@@ -30,6 +30,8 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators
|
|||||||
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 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators
|
|||||||
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 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators
|
|||||||
|
|
||||||
_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)
|
||||||
{
|
{
|
||||||
|
@@ -17,6 +17,8 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenter
|
|||||||
Confidence.Tag,
|
Confidence.Tag,
|
||||||
quality.Quality.Resolution,
|
quality.Quality.Resolution,
|
||||||
Confidence.Tag,
|
Confidence.Tag,
|
||||||
|
quality.Quality.Modifier,
|
||||||
|
Confidence.Tag,
|
||||||
quality.Revision);
|
quality.Revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,8 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenter
|
|||||||
confidence,
|
confidence,
|
||||||
quality.Quality.Resolution,
|
quality.Quality.Resolution,
|
||||||
confidence,
|
confidence,
|
||||||
|
quality.Quality.Modifier,
|
||||||
|
confidence,
|
||||||
quality.Revision);
|
quality.Revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenter
|
|||||||
Confidence.Tag,
|
Confidence.Tag,
|
||||||
quality.Quality.Resolution,
|
quality.Quality.Resolution,
|
||||||
Confidence.Tag,
|
Confidence.Tag,
|
||||||
|
quality.Quality.Modifier,
|
||||||
|
Confidence.Tag,
|
||||||
quality.Revision);
|
quality.Revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,29 +9,40 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenter
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ namespace NzbDrone.Core.Parser
|
|||||||
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);
|
||||||
|
@@ -213,16 +213,5 @@ namespace NzbDrone.Core.Qualities
|
|||||||
{
|
{
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,9 +9,9 @@ namespace NzbDrone.Core.Qualities
|
|||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user