mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Fixed: Quality Resolution determination using MediaInfo
This commit is contained in:
parent
e66b28fb87
commit
06c7f6034d
@ -10,31 +10,34 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
|
|||||||
{
|
{
|
||||||
public class AggregateQuality : IAggregateLocalEpisode
|
public class AggregateQuality : IAggregateLocalEpisode
|
||||||
{
|
{
|
||||||
private readonly IEnumerable<IAugmentQuality> _augmentQualities;
|
private readonly List<IAugmentQuality> _augmentQualities;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public AggregateQuality(IEnumerable<IAugmentQuality> augmentQualities,
|
public AggregateQuality(IEnumerable<IAugmentQuality> augmentQualities,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_augmentQualities = augmentQualities;
|
_augmentQualities = augmentQualities.OrderBy(a => a.Order).ToList();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalEpisode Aggregate(LocalEpisode localEpisode, DownloadClientItem downloadClientItem, bool otherFiles)
|
public LocalEpisode Aggregate(LocalEpisode localEpisode, DownloadClientItem downloadClientItem, bool otherFiles)
|
||||||
{
|
{
|
||||||
var augmentedQualities = _augmentQualities.OrderBy(a => a.Order)
|
|
||||||
.Select(a => a.AugmentQuality(localEpisode, downloadClientItem))
|
|
||||||
.Where(a => a != null)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var source = QualitySource.Unknown;
|
var source = QualitySource.Unknown;
|
||||||
var sourceConfidence = Confidence.Default;
|
var sourceConfidence = Confidence.Default;
|
||||||
var resolution = 0;
|
var resolution = 0;
|
||||||
var resolutionConfidence = Confidence.Default;
|
var resolutionConfidence = Confidence.Default;
|
||||||
var revision = new Revision();
|
var revision = new Revision();
|
||||||
|
|
||||||
foreach (var augmentedQuality in augmentedQualities)
|
foreach (var augmentQuality in _augmentQualities)
|
||||||
{
|
{
|
||||||
|
var augmentedQuality = augmentQuality.AugmentQuality(localEpisode, downloadClientItem);
|
||||||
|
if (augmentedQuality == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Trace("Considering Source {0} ({1}) Resolution {2} ({3}) Revision {4} from {5}", augmentedQuality.Source, augmentedQuality.SourceConfidence, augmentedQuality.Resolution, augmentedQuality.ResolutionConfidence, augmentedQuality.Revision, augmentQuality.Name);
|
||||||
|
|
||||||
if (source == QualitySource.Unknown ||
|
if (source == QualitySource.Unknown ||
|
||||||
augmentedQuality.SourceConfidence > sourceConfidence && augmentedQuality.Source != QualitySource.Unknown)
|
augmentedQuality.SourceConfidence > sourceConfidence && augmentedQuality.Source != QualitySource.Unknown)
|
||||||
{
|
{
|
||||||
@ -55,7 +58,7 @@ public LocalEpisode Aggregate(LocalEpisode localEpisode, DownloadClientItem down
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Trace("Finding quality. Source: {0}. Resolution: {1}", source, resolution);
|
_logger.Trace("Selected Source {0} ({1}) Resolution {2} ({3}) Revision {4}", source, sourceConfidence, resolution, resolutionConfidence, revision);
|
||||||
|
|
||||||
var quality = new QualityModel(QualityFinder.FindBySourceAndResolution(source, resolution), revision);
|
var quality = new QualityModel(QualityFinder.FindBySourceAndResolution(source, resolution), revision);
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
public class AugmentQualityFromDownloadClientItem : IAugmentQuality
|
public class AugmentQualityFromDownloadClientItem : IAugmentQuality
|
||||||
{
|
{
|
||||||
public int Order => 3;
|
public int Order => 3;
|
||||||
|
public string Name => "DownloadClientItem";
|
||||||
|
|
||||||
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
public class AugmentQualityFromFileName : IAugmentQuality
|
public class AugmentQualityFromFileName : IAugmentQuality
|
||||||
{
|
{
|
||||||
public int Order => 1;
|
public int Order => 1;
|
||||||
|
public string Name => "FileName";
|
||||||
|
|
||||||
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
public class AugmentQualityFromFolder : IAugmentQuality
|
public class AugmentQualityFromFolder : IAugmentQuality
|
||||||
{
|
{
|
||||||
public int Order => 2;
|
public int Order => 2;
|
||||||
|
public string Name => "FolderName";
|
||||||
|
|
||||||
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using NLog;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
@ -5,7 +6,15 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
{
|
{
|
||||||
public class AugmentQualityFromMediaInfo : IAugmentQuality
|
public class AugmentQualityFromMediaInfo : IAugmentQuality
|
||||||
{
|
{
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public int Order => 4;
|
public int Order => 4;
|
||||||
|
public string Name => "MediaInfo";
|
||||||
|
|
||||||
|
public AugmentQualityFromMediaInfo(Logger logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
@ -15,27 +24,35 @@ public AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadCl
|
|||||||
}
|
}
|
||||||
|
|
||||||
var width = localEpisode.MediaInfo.Width;
|
var width = localEpisode.MediaInfo.Width;
|
||||||
|
var height = localEpisode.MediaInfo.Height;
|
||||||
|
|
||||||
if (width >= 3200)
|
|
||||||
|
if (width >= 3200 || height >= 2100)
|
||||||
{
|
{
|
||||||
|
_logger.Trace("Resolution {0}x{1} considered 2160p", width, height);
|
||||||
return AugmentQualityResult.ResolutionOnly(2160, Confidence.MediaInfo);
|
return AugmentQualityResult.ResolutionOnly(2160, Confidence.MediaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width >= 1800)
|
if (width >= 1800 || height >= 1000)
|
||||||
{
|
{
|
||||||
|
_logger.Trace("Resolution {0}x{1} considered 1080p", width, height);
|
||||||
return AugmentQualityResult.ResolutionOnly(1080, Confidence.MediaInfo);
|
return AugmentQualityResult.ResolutionOnly(1080, Confidence.MediaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width >= 1200)
|
if (width >= 1200 || height >= 700)
|
||||||
{
|
{
|
||||||
|
_logger.Trace("Resolution {0}x{1} considered 720p", width, height);
|
||||||
return AugmentQualityResult.ResolutionOnly(720, Confidence.MediaInfo);
|
return AugmentQualityResult.ResolutionOnly(720, Confidence.MediaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > 0)
|
if (width > 0 || height > 0)
|
||||||
{
|
{
|
||||||
|
_logger.Trace("Resolution {0}x{1} considered 480p", width, height);
|
||||||
return AugmentQualityResult.ResolutionOnly(480, Confidence.MediaInfo);
|
return AugmentQualityResult.ResolutionOnly(480, Confidence.MediaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.Trace("Resolution {0}x{1}", width, height);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
public class AugmentQualityFromReleaseName : IAugmentQuality
|
public class AugmentQualityFromReleaseName : IAugmentQuality
|
||||||
{
|
{
|
||||||
public int Order => 5;
|
public int Order => 5;
|
||||||
|
public string Name => "ReleaseName";
|
||||||
|
|
||||||
private readonly IDownloadHistoryService _downloadHistoryService;
|
private readonly IDownloadHistoryService _downloadHistoryService;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
{
|
{
|
||||||
public class AugmentQualityResult
|
public class AugmentQualityResult
|
||||||
{
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
public QualitySource Source { get; set; }
|
public QualitySource Source { get; set; }
|
||||||
public Confidence SourceConfidence { get; set; }
|
public Confidence SourceConfidence { get; set; }
|
||||||
public int Resolution { get; set; }
|
public int Resolution { get; set; }
|
||||||
|
@ -6,6 +6,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators.Augment
|
|||||||
public interface IAugmentQuality
|
public interface IAugmentQuality
|
||||||
{
|
{
|
||||||
int Order { get; }
|
int Order { get; }
|
||||||
|
string Name { get; }
|
||||||
AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem);
|
AugmentQualityResult AugmentQuality(LocalEpisode localEpisode, DownloadClientItem downloadClientItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user