mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-17 21:26:22 -04:00
New: Use file's format title for quality if parsed
Closes #7993 (cherry picked from commit 599ad86657bbb8125c4354000cfc94331041f984)
This commit is contained in:
Binary file not shown.
@@ -50,7 +50,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
info.AudioFormat.Should().Be("aac");
|
||||
info.AudioCodecID.Should().Be("mp4a");
|
||||
info.AudioProfile.Should().Be("LC");
|
||||
info.AudioBitrate.Should().Be(125488);
|
||||
info.AudioBitrate.Should().Be(125509);
|
||||
info.AudioChannels.Should().Be(2);
|
||||
info.AudioChannelPositions.Should().Be("stereo");
|
||||
info.AudioLanguages.Should().BeEquivalentTo("eng");
|
||||
@@ -58,12 +58,13 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
info.RunTime.Seconds.Should().Be(10);
|
||||
info.ScanType.Should().Be("Progressive");
|
||||
info.Subtitles.Should().BeEmpty();
|
||||
info.VideoBitrate.Should().Be(193328);
|
||||
info.VideoBitrate.Should().Be(193694);
|
||||
info.VideoFps.Should().Be(24);
|
||||
info.Width.Should().Be(480);
|
||||
info.VideoBitDepth.Should().Be(8);
|
||||
info.VideoColourPrimaries.Should().Be("smpte170m");
|
||||
info.VideoTransferCharacteristics.Should().Be("bt709");
|
||||
info.Title.Should().Be("Sample Title");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -86,7 +87,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
info.AudioFormat.Should().Be("aac");
|
||||
info.AudioCodecID.Should().Be("mp4a");
|
||||
info.AudioProfile.Should().Be("LC");
|
||||
info.AudioBitrate.Should().Be(125488);
|
||||
info.AudioBitrate.Should().Be(125509);
|
||||
info.AudioChannels.Should().Be(2);
|
||||
info.AudioChannelPositions.Should().Be("stereo");
|
||||
info.AudioLanguages.Should().BeEquivalentTo("eng");
|
||||
@@ -94,11 +95,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
info.RunTime.Seconds.Should().Be(10);
|
||||
info.ScanType.Should().Be("Progressive");
|
||||
info.Subtitles.Should().BeEmpty();
|
||||
info.VideoBitrate.Should().Be(193328);
|
||||
info.VideoBitrate.Should().Be(193694);
|
||||
info.VideoFps.Should().Be(24);
|
||||
info.Width.Should().Be(480);
|
||||
info.VideoColourPrimaries.Should().Be("smpte170m");
|
||||
info.VideoTransferCharacteristics.Should().Be("bt709");
|
||||
info.Title.Should().Be("Sample Title");
|
||||
}
|
||||
|
||||
[TestCase(8, "", "", "", null, HdrFormat.None)]
|
||||
|
||||
@@ -5,6 +5,7 @@ using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenters.Quality;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenters.Quality
|
||||
@@ -68,6 +69,47 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Aggregation.Aggregators.Augm
|
||||
|
||||
result.Should().NotBe(null);
|
||||
result.Resolution.Should().Be((int)expectedResolution);
|
||||
result.Source.Should().Be(Source.UNKNOWN);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_include_source_if_extracted_from_title()
|
||||
{
|
||||
var mediaInfo = Builder<MediaInfoModel>.CreateNew()
|
||||
.With(m => m.Width = 1920)
|
||||
.With(m => m.Height = 1080)
|
||||
.With(m => m.Title = "Movie.Title.2008.WEB.x264-Radarr")
|
||||
.Build();
|
||||
|
||||
var localMovie = Builder<LocalMovie>.CreateNew()
|
||||
.With(l => l.MediaInfo = mediaInfo)
|
||||
.Build();
|
||||
|
||||
var result = Subject.AugmentQuality(localMovie, null);
|
||||
|
||||
result.Should().NotBe(null);
|
||||
result.Resolution.Should().Be(1080);
|
||||
result.Source.Should().Be(Source.WEBDL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_have_unknown_source_if_no_source_extracted_from_title()
|
||||
{
|
||||
var mediaInfo = Builder<MediaInfoModel>.CreateNew()
|
||||
.With(m => m.Width = 1920)
|
||||
.With(m => m.Height = 1080)
|
||||
.With(m => m.Title = "Movie.Title.2008.x264-Radarr")
|
||||
.Build();
|
||||
|
||||
var localMovie = Builder<LocalMovie>.CreateNew()
|
||||
.With(l => l.MediaInfo = mediaInfo)
|
||||
.Build();
|
||||
|
||||
var result = Subject.AugmentQuality(localMovie, null);
|
||||
|
||||
result.Should().NotBe(null);
|
||||
result.Resolution.Should().Be(1080);
|
||||
result.Source.Should().Be(Source.UNKNOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using FFMpegCore;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
@@ -59,5 +60,8 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||
public List<string> Subtitles { get; set; }
|
||||
|
||||
public string ScanType { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
|
||||
mediaInfoModel.RawStreamData = ffprobeOutput;
|
||||
mediaInfoModel.SchemaRevision = CURRENT_MEDIA_INFO_SCHEMA_REVISION;
|
||||
|
||||
if (analysis.Format.Tags?.TryGetValue("title", out var title) ?? false)
|
||||
{
|
||||
mediaInfoModel.Title = title;
|
||||
}
|
||||
|
||||
FFProbeFrames frames = null;
|
||||
|
||||
// if it looks like PQ10 or similar HDR, do a frame analysis to figure out which type it is
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenters.Quality
|
||||
{
|
||||
@@ -26,35 +28,51 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenter
|
||||
|
||||
var width = localMovie.MediaInfo.Width;
|
||||
var height = localMovie.MediaInfo.Height;
|
||||
var source = Source.UNKNOWN;
|
||||
var sourceConfidence = Confidence.Default;
|
||||
var title = localMovie.MediaInfo.Title;
|
||||
|
||||
if (title.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
var parsedQuality = QualityParser.ParseQualityName(title.Trim());
|
||||
|
||||
// Only use the quality if it's not unknown and the source is from the name (which is MediaInfo's title in this case)
|
||||
if (parsedQuality.Quality.Source != Source.UNKNOWN &&
|
||||
parsedQuality.SourceDetectionSource == QualityDetectionSource.Name)
|
||||
{
|
||||
source = parsedQuality.Quality.Source;
|
||||
sourceConfidence = Confidence.MediaInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (width >= 3200 || height >= 2100)
|
||||
{
|
||||
_logger.Trace("Resolution {0}x{1} considered 2160p", width, height);
|
||||
return AugmentQualityResult.ResolutionOnly((int)Resolution.R2160p, Confidence.MediaInfo);
|
||||
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, (int)Resolution.R2160p, Confidence.MediaInfo);
|
||||
}
|
||||
|
||||
if (width >= 1800 || height >= 1000)
|
||||
{
|
||||
_logger.Trace("Resolution {0}x{1} considered 1080p", width, height);
|
||||
return AugmentQualityResult.ResolutionOnly((int)Resolution.R1080p, Confidence.MediaInfo);
|
||||
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, (int)Resolution.R1080p, Confidence.MediaInfo);
|
||||
}
|
||||
|
||||
if (width >= 1200 || height >= 700)
|
||||
{
|
||||
_logger.Trace("Resolution {0}x{1} considered 720p", width, height);
|
||||
return AugmentQualityResult.ResolutionOnly((int)Resolution.R720p, Confidence.MediaInfo);
|
||||
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, (int)Resolution.R720p, Confidence.MediaInfo);
|
||||
}
|
||||
|
||||
if (width >= 1000 || height >= 560)
|
||||
{
|
||||
_logger.Trace("Resolution {0}x{1} considered 576p", width, height);
|
||||
return AugmentQualityResult.ResolutionOnly((int)Resolution.R576p, Confidence.MediaInfo);
|
||||
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, (int)Resolution.R576p, Confidence.MediaInfo);
|
||||
}
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
_logger.Trace("Resolution {0}x{1} considered 480p", width, height);
|
||||
return AugmentQualityResult.ResolutionOnly((int)Resolution.R480p, Confidence.MediaInfo);
|
||||
return AugmentQualityResult.SourceAndResolutionOnly(source, sourceConfidence, (int)Resolution.R480p, Confidence.MediaInfo);
|
||||
}
|
||||
|
||||
_logger.Trace("Resolution {0}x{1}", width, height);
|
||||
|
||||
@@ -47,5 +47,10 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators.Augmenter
|
||||
{
|
||||
return new AugmentQualityResult(Source.UNKNOWN, Confidence.Default, 0, Confidence.Default, modifier, modifierConfidence, null, Confidence.Default);
|
||||
}
|
||||
|
||||
public static AugmentQualityResult SourceAndResolutionOnly(Source source, Confidence sourceConfidence, int resolution, Confidence resolutionConfidence)
|
||||
{
|
||||
return new AugmentQualityResult(source, sourceConfidence, resolution, resolutionConfidence, Modifier.NONE, Confidence.Default, null, Confidence.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user