mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-22 22:43:31 -07:00
Use MediaInfo to correctly identify quality when scanning disk as some file names may not contain the real quality.
Fixes #170
This commit is contained in:
parent
d18b15d504
commit
3a0278d0a1
4 changed files with 118 additions and 9 deletions
|
@ -178,7 +178,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
_mediaFileTableCleanupService.Clean(movie, mediaFileList);
|
_mediaFileTableCleanupService.Clean(movie, mediaFileList);
|
||||||
|
|
||||||
var decisionsStopwatch = Stopwatch.StartNew();
|
var decisionsStopwatch = Stopwatch.StartNew();
|
||||||
var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, movie);
|
var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, movie, true);
|
||||||
decisionsStopwatch.Stop();
|
decisionsStopwatch.Stop();
|
||||||
_logger.Trace("Import decisions complete for: {0} [{1}]", movie, decisionsStopwatch.Elapsed);
|
_logger.Trace("Import decisions complete for: {0} [{1}]", movie, decisionsStopwatch.Elapsed);
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), movie, folderInfo, true);
|
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), movie, folderInfo, true, false);
|
||||||
var importResults = _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
|
var importResults = _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
|
||||||
|
|
||||||
if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) &&
|
if ((downloadClientItem == null || !downloadClientItem.IsReadOnly) &&
|
||||||
|
@ -237,7 +237,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, movie, null, true);
|
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, movie, null, true, false);
|
||||||
|
|
||||||
return _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
|
return _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series);
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie);
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource); //TODO: Needs changing to ParsedMovieInfo!!
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, bool shouldCheckQuality);
|
||||||
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality); //TODO: Needs changing to ParsedMovieInfo!!
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
private readonly IVideoFileInfoReader _videoFileInfoReader;
|
private readonly IVideoFileInfoReader _videoFileInfoReader;
|
||||||
private readonly IDetectSample _detectSample;
|
private readonly IDetectSample _detectSample;
|
||||||
|
private readonly IQualityDefinitionService _qualitiesService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ImportDecisionMaker(IEnumerable<IImportDecisionEngineSpecification> specifications,
|
public ImportDecisionMaker(IEnumerable<IImportDecisionEngineSpecification> specifications,
|
||||||
|
@ -39,6 +41,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
IDiskProvider diskProvider,
|
IDiskProvider diskProvider,
|
||||||
IVideoFileInfoReader videoFileInfoReader,
|
IVideoFileInfoReader videoFileInfoReader,
|
||||||
IDetectSample detectSample,
|
IDetectSample detectSample,
|
||||||
|
IQualityDefinitionService qualitiesService,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_specifications = specifications;
|
_specifications = specifications;
|
||||||
|
@ -47,6 +50,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_videoFileInfoReader = videoFileInfoReader;
|
_videoFileInfoReader = videoFileInfoReader;
|
||||||
_detectSample = detectSample;
|
_detectSample = detectSample;
|
||||||
|
_qualitiesService = qualitiesService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +61,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
|
|
||||||
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie)
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie)
|
||||||
{
|
{
|
||||||
return GetImportDecisions(videoFiles, movie, null, true);
|
return GetImportDecisions(videoFiles, movie, null, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, bool shouldCheckQuality = false)
|
||||||
|
{
|
||||||
|
return GetImportDecisions(videoFiles, movie, null, true, shouldCheckQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource)
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource)
|
||||||
|
@ -77,7 +86,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
return decisions;
|
return decisions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource)
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality = false)
|
||||||
{
|
{
|
||||||
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
|
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
|
||||||
|
|
||||||
|
@ -88,13 +97,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
|
|
||||||
foreach (var file in newFiles)
|
foreach (var file in newFiles)
|
||||||
{
|
{
|
||||||
decisions.AddIfNotNull(GetDecision(file, movie, folderInfo, sceneSource, shouldUseFolderName));
|
decisions.AddIfNotNull(GetDecision(file, movie, folderInfo, sceneSource, shouldUseFolderName, shouldCheckQuality));
|
||||||
}
|
}
|
||||||
|
|
||||||
return decisions;
|
return decisions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImportDecision GetDecision(string file, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldUseFolderName)
|
private ImportDecision GetDecision(string file, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldUseFolderName, bool shouldCheckQuality = false)
|
||||||
{
|
{
|
||||||
ImportDecision decision = null;
|
ImportDecision decision = null;
|
||||||
|
|
||||||
|
@ -113,6 +122,106 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
if (sceneSource)
|
if (sceneSource)
|
||||||
{
|
{
|
||||||
localMovie.MediaInfo = _videoFileInfoReader.GetMediaInfo(file);
|
localMovie.MediaInfo = _videoFileInfoReader.GetMediaInfo(file);
|
||||||
|
if (shouldCheckQuality)
|
||||||
|
{
|
||||||
|
var width = localMovie.MediaInfo.Width;
|
||||||
|
var current = localMovie.Quality;
|
||||||
|
var qualityName = current.Quality.Name.ToLower();
|
||||||
|
QualityModel updated = null;
|
||||||
|
if (width > 1400)
|
||||||
|
{
|
||||||
|
if (qualityName.Contains("bluray"))
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.Bluray1080p);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (qualityName.Contains("webdl"))
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.WEBDL1080p);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (qualityName.Contains("hdtv"))
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.HDTV1080p);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var def = _qualitiesService.Get(Quality.HDTV1080p);
|
||||||
|
if (localMovie.Size > def.MinSize && def.MaxSize > localMovie.Size)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.HDTV1080p);
|
||||||
|
}
|
||||||
|
def = _qualitiesService.Get(Quality.WEBDL1080p);
|
||||||
|
if (localMovie.Size > def.MinSize && def.MaxSize > localMovie.Size)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.WEBDL1080p);
|
||||||
|
}
|
||||||
|
def = _qualitiesService.Get(Quality.Bluray1080p);
|
||||||
|
if (localMovie.Size > def.MinSize && def.MaxSize > localMovie.Size)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.Bluray1080p);
|
||||||
|
}
|
||||||
|
if (updated == null)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.Bluray1080p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (width > 900)
|
||||||
|
{
|
||||||
|
if (qualityName.Contains("bluray"))
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.Bluray720p);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (qualityName.Contains("webdl"))
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.WEBDL720p);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (qualityName.Contains("hdtv"))
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.HDTV720p);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var def = _qualitiesService.Get(Quality.HDTV720p);
|
||||||
|
if (localMovie.Size > def.MinSize && def.MaxSize > localMovie.Size)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.HDTV720p);
|
||||||
|
}
|
||||||
|
def = _qualitiesService.Get(Quality.WEBDL720p);
|
||||||
|
if (localMovie.Size > def.MinSize && def.MaxSize > localMovie.Size)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.WEBDL720p);
|
||||||
|
}
|
||||||
|
def = _qualitiesService.Get(Quality.Bluray720p);
|
||||||
|
if (localMovie.Size > def.MinSize && def.MaxSize > localMovie.Size)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.Bluray720p);
|
||||||
|
}
|
||||||
|
if (updated == null)
|
||||||
|
{
|
||||||
|
updated = new QualityModel(Quality.Bluray720p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (updated != null && updated != current)
|
||||||
|
{
|
||||||
|
updated.QualitySource = QualitySource.MediaInfo;
|
||||||
|
localMovie.Quality = updated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decision = GetDecision(localMovie);
|
decision = GetDecision(localMovie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
|
||||||
}
|
}
|
||||||
|
|
||||||
var importDecisions = _importDecisionMaker.GetImportDecisions(new List<string> { file },
|
var importDecisions = _importDecisionMaker.GetImportDecisions(new List<string> { file },
|
||||||
movie, null, SceneSource(movie, folder));
|
movie, null, SceneSource(movie, folder), true);
|
||||||
|
|
||||||
return importDecisions.Any() ? MapItem(importDecisions.First(), folder, downloadId) : null;
|
return importDecisions.Any() ? MapItem(importDecisions.First(), folder, downloadId) : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue