Fixed: Aggregating media files with 576p resolution

pull/7236/head
Mark McDowall 5 months ago committed by Mark McDowall
parent 4b72a0a4e8
commit ca38a9b577

@ -170,5 +170,41 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
result.Quality.Revision.Version.Should().Be(2);
result.Quality.RevisionDetectionSource.Should().Be(QualityDetectionSource.Name);
}
[Test]
public void should_return_Bluray576p_when_Bluray_came_from_name_and_mediainfo_indicates_576p()
{
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(new AugmentQualityResult(QualitySource.Bluray, Confidence.Default, 480, Confidence.Default, new Revision(0), Confidence.Tag));
_mediaInfoAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(AugmentQualityResult.ResolutionOnly(576, Confidence.MediaInfo));
GivenAugmenters(_nameAugmenter, _mediaInfoAugmenter);
var result = Subject.Aggregate(new LocalEpisode(), null);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.MediaInfo);
result.Quality.Quality.Should().Be(Quality.Bluray576p);
}
[Test]
public void should_return_SDTV_when_HDTV_came_from_name_and_mediainfo_indicates_576p()
{
_nameAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(new AugmentQualityResult(QualitySource.Television, Confidence.Default, 480, Confidence.Default, new Revision(0), Confidence.Tag));
_mediaInfoAugmenter.Setup(s => s.AugmentQuality(It.IsAny<LocalEpisode>(), It.IsAny<DownloadClientItem>()))
.Returns(AugmentQualityResult.ResolutionOnly(576, Confidence.MediaInfo));
GivenAugmenters(_nameAugmenter, _mediaInfoAugmenter);
var result = Subject.Aggregate(new LocalEpisode(), null);
result.Quality.SourceDetectionSource.Should().Be(QualityDetectionSource.Name);
result.Quality.ResolutionDetectionSource.Should().Be(QualityDetectionSource.MediaInfo);
result.Quality.Quality.Should().Be(Quality.SDTV);
}
}
}

@ -47,6 +47,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators.Au
[TestCase(1490, 1, 720)]
[TestCase(1280, 1, 720)] // HD
[TestCase(1200, 1, 720)]
[TestCase(1000, 1, 576)]
[TestCase(720, 576, 576)]
[TestCase(800, 1, 480)]
[TestCase(720, 1, 480)] // SDTV
[TestCase(600, 1, 480)]
@ -108,5 +110,25 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators.Au
result.Resolution.Should().Be(1080);
result.Source.Should().Be(QualitySource.Unknown);
}
[Test]
public void should_include_source_for_576_if_extracted_from_title()
{
var mediaInfo = Builder<MediaInfoModel>.CreateNew()
.With(m => m.Width = 1024)
.With(m => m.Height = 576)
.With(m => m.Title = "Series.Title.S01E05.Bluray.x264-Sonarr")
.Build();
var localEpisode = Builder<LocalEpisode>.CreateNew()
.With(l => l.MediaInfo = mediaInfo)
.Build();
var result = Subject.AugmentQuality(localEpisode, null);
result.Should().NotBe(null);
result.Resolution.Should().Be(576);
result.Source.Should().Be(QualitySource.Bluray);
}
}
}

@ -63,6 +63,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, 720, Confidence.MediaInfo);
}
if (width >= 1000 || height >= 560)
{
_logger.Trace("Resolution {0}x{1} considered 576p", width, height);
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, 576, Confidence.MediaInfo);
}
if (width > 0 && height > 0)
{
_logger.Trace("Resolution {0}x{1} considered 480p", width, height);

@ -17,6 +17,20 @@ namespace NzbDrone.Core.Qualities
return matchingQuality;
}
// Handle 576p releases that have a Television or Web source, so they don't get rolled up to Bluray 576p
if (resolution < 720)
{
switch (source)
{
case QualitySource.Television:
return Quality.SDTV;
case QualitySource.Web:
return Quality.WEBDL480p;
case QualitySource.WebRip:
return Quality.WEBRip480p;
}
}
var matchingResolution = Quality.All.Where(q => q.Resolution == resolution)
.OrderBy(q => q.Source)
.ToList();

Loading…
Cancel
Save