mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Added: Files downloaded with different quality than grabbed will get rejected.
Fixes #1779, Fixes #2087, Fixes #1321
This commit is contained in:
parent
aab14d02f9
commit
78e5fdf3bc
@ -14,6 +14,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
@ -77,7 +78,7 @@ public void should_skip_if_no_series_found()
|
|||||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<ParsedMovieInfo>(), It.IsAny<bool>()),
|
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), It.IsAny<ParsedMovieInfo>(), It.IsAny<bool>()),
|
||||||
Times.Never());
|
Times.Never());
|
||||||
|
|
||||||
VerifyNoImport();
|
VerifyNoImport();
|
||||||
@ -128,7 +129,7 @@ public void should_not_delete_folder_if_files_were_imported_and_video_files_rema
|
|||||||
imported.Add(new ImportDecision(localMovie));
|
imported.Add(new ImportDecision(localMovie));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedMovie>()
|
Mocker.GetMock<IImportApprovedMovie>()
|
||||||
@ -154,7 +155,7 @@ public void should_delete_folder_if_files_were_imported_and_only_sample_files_re
|
|||||||
imported.Add(new ImportDecision(localMovie));
|
imported.Add(new ImportDecision(localMovie));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedMovie>()
|
Mocker.GetMock<IImportApprovedMovie>()
|
||||||
@ -226,7 +227,7 @@ public void should_not_delete_if_there_is_large_rar_file()
|
|||||||
imported.Add(new ImportDecision(localMovie));
|
imported.Add(new ImportDecision(localMovie));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedMovie>()
|
Mocker.GetMock<IImportApprovedMovie>()
|
||||||
@ -280,7 +281,7 @@ public void should_use_folder_if_folder_import()
|
|||||||
Subject.ProcessPath(fileName);
|
Subject.ProcessPath(fileName);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<ParsedMovieInfo>(), true, false), Times.Once());
|
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), It.IsAny<ParsedMovieInfo>(), true, false), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -304,7 +305,7 @@ public void should_not_use_folder_if_file_import()
|
|||||||
var result = Subject.ProcessPath(fileName);
|
var result = Subject.ProcessPath(fileName);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true, false), Times.Once());
|
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true, false), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -337,7 +338,7 @@ public void should_not_delete_if_no_files_were_imported()
|
|||||||
imported.Add(new ImportDecision(localMovie));
|
imported.Add(new ImportDecision(localMovie));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Movie>(), It.IsAny<DownloadClientItem>(), null, true))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
@ -187,7 +187,7 @@ private List<ImportResult> ProcessFolder(DirectoryInfo directoryInfo, ImportMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), movie, folderInfo, true, false);
|
var decisions = _importDecisionMaker.GetImportDecisions(videoFiles.ToList(), movie, null, 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) &&
|
||||||
@ -241,7 +241,7 @@ private List<ImportResult> ProcessFile(FileInfo fileInfo, ImportMode importMode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, movie, null, true, false);
|
var decisions = _importDecisionMaker.GetImportDecisions(new List<string>() { fileInfo.FullName }, movie, null, null, true, false);
|
||||||
|
|
||||||
return _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
|
return _importApprovedMovie.Import(decisions, true, downloadClientItem, importMode);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
@ -7,6 +8,6 @@ public interface IImportDecisionEngineSpecification
|
|||||||
{
|
{
|
||||||
Decision IsSatisfiedBy(LocalEpisode localEpisode);
|
Decision IsSatisfiedBy(LocalEpisode localEpisode);
|
||||||
|
|
||||||
Decision IsSatisfiedBy(LocalMovie localMovie);
|
Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
@ -20,8 +21,8 @@ public interface IMakeImportDecision
|
|||||||
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, bool shouldCheckQuality);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, bool shouldCheckQuality);
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality);
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource);
|
||||||
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
|
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,12 +63,12 @@ public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series s
|
|||||||
|
|
||||||
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie)
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie)
|
||||||
{
|
{
|
||||||
return GetImportDecisions(videoFiles, movie, null, true, false);
|
return GetImportDecisions(videoFiles, movie, null, null, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, bool shouldCheckQuality = false)
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, bool shouldCheckQuality = false)
|
||||||
{
|
{
|
||||||
return GetImportDecisions(videoFiles, movie, null, true, shouldCheckQuality);
|
return GetImportDecisions(videoFiles, movie, null, 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)
|
||||||
@ -87,7 +88,7 @@ public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series s
|
|||||||
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, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource)
|
||||||
{
|
{
|
||||||
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
|
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
|
||||||
|
|
||||||
@ -98,13 +99,13 @@ public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie mo
|
|||||||
|
|
||||||
foreach (var file in newFiles)
|
foreach (var file in newFiles)
|
||||||
{
|
{
|
||||||
decisions.AddIfNotNull(GetDecision(file, movie, folderInfo, sceneSource, shouldUseFolderName));
|
decisions.AddIfNotNull(GetDecision(file, movie, downloadClientItem, folderInfo, sceneSource, shouldUseFolderName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return decisions;
|
return decisions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality = false)
|
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldCheckQuality)
|
||||||
{
|
{
|
||||||
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
|
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
|
||||||
|
|
||||||
@ -115,13 +116,13 @@ public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie mo
|
|||||||
|
|
||||||
foreach (var file in newFiles)
|
foreach (var file in newFiles)
|
||||||
{
|
{
|
||||||
decisions.AddIfNotNull(GetDecision(file, movie, folderInfo, sceneSource, shouldUseFolderName, shouldCheckQuality));
|
decisions.AddIfNotNull(GetDecision(file, movie, downloadClientItem, folderInfo, sceneSource, shouldUseFolderName, shouldCheckQuality));
|
||||||
}
|
}
|
||||||
|
|
||||||
return decisions;
|
return decisions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImportDecision GetDecision(string file, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldUseFolderName, bool shouldCheckQuality = false)
|
private ImportDecision GetDecision(string file, Movie movie, DownloadClientItem downloadClientItem, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldUseFolderName, bool shouldCheckQuality = false)
|
||||||
{
|
{
|
||||||
ImportDecision decision = null;
|
ImportDecision decision = null;
|
||||||
|
|
||||||
@ -283,11 +284,11 @@ private ImportDecision GetDecision(string file, Movie movie, ParsedMovieInfo fol
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
decision = GetDecision(localMovie);
|
decision = GetDecision(localMovie, downloadClientItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decision = GetDecision(localMovie);
|
decision = GetDecision(localMovie, downloadClientItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,9 +315,9 @@ private ImportDecision GetDecision(string file, Movie movie, ParsedMovieInfo fol
|
|||||||
return decision;
|
return decision;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImportDecision GetDecision(LocalMovie localMovie)
|
private ImportDecision GetDecision(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
var reasons = _specifications.Select(c => EvaluateSpec(c, localMovie))
|
var reasons = _specifications.Select(c => EvaluateSpec(c, localMovie, downloadClientItem))
|
||||||
.Where(c => c != null);
|
.Where(c => c != null);
|
||||||
|
|
||||||
return new ImportDecision(localMovie, reasons.ToArray());
|
return new ImportDecision(localMovie, reasons.ToArray());
|
||||||
@ -385,11 +386,11 @@ private ImportDecision GetDecision(LocalEpisode localEpisode)
|
|||||||
return new ImportDecision(localEpisode, reasons.ToArray());
|
return new ImportDecision(localEpisode, reasons.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rejection EvaluateSpec(IImportDecisionEngineSpecification spec, LocalMovie localMovie)
|
private Rejection EvaluateSpec(IImportDecisionEngineSpecification spec, LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = spec.IsSatisfiedBy(localMovie);
|
var result = spec.IsSatisfiedBy(localMovie, downloadClientItem);
|
||||||
|
|
||||||
if (!result.Accepted)
|
if (!result.Accepted)
|
||||||
{
|
{
|
||||||
|
@ -104,13 +104,19 @@ public List<ManualImportItem> GetMediaFiles(string path, string downloadId)
|
|||||||
|
|
||||||
private List<ManualImportItem> ProcessFolder(string folder, string downloadId)
|
private List<ManualImportItem> ProcessFolder(string folder, string downloadId)
|
||||||
{
|
{
|
||||||
|
DownloadClientItem downloadClientItem = null;
|
||||||
var directoryInfo = new DirectoryInfo(folder);
|
var directoryInfo = new DirectoryInfo(folder);
|
||||||
var series = _parsingService.GetMovie(directoryInfo.Name);
|
var series = _parsingService.GetMovie(directoryInfo.Name);
|
||||||
|
|
||||||
if (series == null && downloadId.IsNotNullOrWhiteSpace())
|
if (downloadId.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var trackedDownload = _trackedDownloadService.Find(downloadId);
|
var trackedDownload = _trackedDownloadService.Find(downloadId);
|
||||||
series = trackedDownload.RemoteMovie.Movie;
|
downloadClientItem = trackedDownload.DownloadItem;
|
||||||
|
|
||||||
|
if (series == null)
|
||||||
|
{
|
||||||
|
series = trackedDownload.RemoteMovie.Movie;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (series == null)
|
if (series == null)
|
||||||
@ -122,7 +128,7 @@ private List<ManualImportItem> ProcessFolder(string folder, string downloadId)
|
|||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name, _config.ParsingLeniency > 0);
|
var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name, _config.ParsingLeniency > 0);
|
||||||
var seriesFiles = _diskScanService.GetVideoFiles(folder).ToList();
|
var seriesFiles = _diskScanService.GetVideoFiles(folder).ToList();
|
||||||
var decisions = _importDecisionMaker.GetImportDecisions(seriesFiles, series, folderInfo, SceneSource(series, folder), false);
|
var decisions = _importDecisionMaker.GetImportDecisions(seriesFiles, series, downloadClientItem, folderInfo, SceneSource(series, folder), false);
|
||||||
|
|
||||||
return decisions.Select(decision => MapItem(decision, folder, downloadId)).ToList();
|
return decisions.Select(decision => MapItem(decision, folder, downloadId)).ToList();
|
||||||
}
|
}
|
||||||
@ -134,6 +140,7 @@ private ManualImportItem ProcessFile(string file, string downloadId, string fold
|
|||||||
folder = new FileInfo(file).Directory.FullName;
|
folder = new FileInfo(file).Directory.FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadClientItem downloadClientItem = null;
|
||||||
var relativeFile = folder.GetRelativePath(file);
|
var relativeFile = folder.GetRelativePath(file);
|
||||||
|
|
||||||
var movie = _parsingService.GetMovie(relativeFile.Split('\\', '/')[0]);
|
var movie = _parsingService.GetMovie(relativeFile.Split('\\', '/')[0]);
|
||||||
@ -143,10 +150,15 @@ private ManualImportItem ProcessFile(string file, string downloadId, string fold
|
|||||||
movie = _parsingService.GetMovie(relativeFile);
|
movie = _parsingService.GetMovie(relativeFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movie == null && downloadId.IsNotNullOrWhiteSpace())
|
if (downloadId.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
var trackedDownload = _trackedDownloadService.Find(downloadId);
|
var trackedDownload = _trackedDownloadService.Find(downloadId);
|
||||||
movie = trackedDownload.RemoteMovie.Movie;
|
downloadClientItem = trackedDownload.DownloadItem;
|
||||||
|
|
||||||
|
if (movie == null)
|
||||||
|
{
|
||||||
|
movie = trackedDownload.RemoteMovie.Movie;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movie == null)
|
if (movie == null)
|
||||||
@ -162,7 +174,7 @@ private ManualImportItem ProcessFile(string file, string downloadId, string fold
|
|||||||
}
|
}
|
||||||
|
|
||||||
var importDecisions = _importDecisionMaker.GetImportDecisions(new List<string> { file },
|
var importDecisions = _importDecisionMaker.GetImportDecisions(new List<string> { file },
|
||||||
movie, null, SceneSource(movie, folder), true);
|
movie, downloadClientItem, null, SceneSource(movie, folder), true);
|
||||||
|
|
||||||
return importDecisions.Any() ? MapItem(importDecisions.First(), folder, downloadId) : new ManualImportItem
|
return importDecisions.Any() ? MapItem(importDecisions.First(), folder, downloadId) : new ManualImportItem
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
@ -64,7 +65,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
|||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localMovie)
|
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
if (_configService.SkipFreeSpaceCheckWhenImporting)
|
if (_configService.SkipFreeSpaceCheckWhenImporting)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
@ -24,7 +25,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
|||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localMovie)
|
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
|
using NzbDrone.Core.History;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
|
{
|
||||||
|
public class GrabbedReleaseQualitySpecification : IImportDecisionEngineSpecification
|
||||||
|
{
|
||||||
|
private readonly Logger _logger;
|
||||||
|
private readonly IHistoryService _historyService;
|
||||||
|
|
||||||
|
public GrabbedReleaseQualitySpecification(Logger logger, IHistoryService historyService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_historyService = historyService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
||||||
|
{
|
||||||
|
var qualityComparer = new QualityModelComparer(localEpisode.Series.Profile);
|
||||||
|
if (localEpisode.Episodes.Any(e => e.EpisodeFileId != 0 && qualityComparer.Compare(e.EpisodeFile.Value.Quality, localEpisode.Quality) > 0))
|
||||||
|
{
|
||||||
|
_logger.Debug("This file isn't an upgrade for all episodes. Skipping {0}", localEpisode.Path);
|
||||||
|
return Decision.Reject("Not an upgrade for existing episode file(s)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem)
|
||||||
|
{
|
||||||
|
if (downloadClientItem == null)
|
||||||
|
{
|
||||||
|
_logger.Debug("No download client item provided, skipping.");
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
var grabbedHistory = _historyService.FindByDownloadId(downloadClientItem.DownloadId)
|
||||||
|
.Where(h => h.EventType == HistoryEventType.Grabbed)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (grabbedHistory.Empty())
|
||||||
|
{
|
||||||
|
_logger.Debug("No grabbed history for this download client item");
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsedReleaseName = Parser.Parser.ParseTitle(grabbedHistory.First().SourceTitle);
|
||||||
|
|
||||||
|
if (parsedReleaseName != null && parsedReleaseName.FullSeason)
|
||||||
|
{
|
||||||
|
_logger.Debug("File is part of a season pack, skipping.");
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in grabbedHistory)
|
||||||
|
{
|
||||||
|
if (item.Quality.Quality != Quality.Unknown && item.Quality != localEpisode.Quality)
|
||||||
|
{
|
||||||
|
_logger.Debug("Quality for grabbed release ({0}) does not match the quality of the file ({1})", item.Quality, localEpisode.Quality);
|
||||||
|
return Decision.Reject("File quality does not match quality of the grabbed release");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
@ -16,7 +17,7 @@ public MatchesFolderSpecification(Logger logger)
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localMovie)
|
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
if (localMovie.ExistingFile)
|
if (localMovie.ExistingFile)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
@ -38,7 +39,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
|||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localEpisode)
|
public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
var sample = _detectSample.IsSample(localEpisode.Movie,
|
var sample = _detectSample.IsSample(localEpisode.Movie,
|
||||||
localEpisode.Quality,
|
localEpisode.Quality,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
@ -57,7 +58,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
|||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localEpisode)
|
public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
if (localEpisode.ExistingFile)
|
if (localEpisode.ExistingFile)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
@ -29,7 +30,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
|||||||
return Decision.Reject("Episode file on disk contains more episodes than this file contains");
|
return Decision.Reject("Episode file on disk contains more episodes than this file contains");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localMovie)
|
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||||
{
|
{
|
||||||
@ -14,7 +15,7 @@ public UnverifiedSceneNumberingSpecification(Logger logger)
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localMovie)
|
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public Decision IsSatisfiedBy(LocalEpisode localEpisode)
|
|||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(LocalMovie localEpisode)
|
public Decision IsSatisfiedBy(LocalMovie localEpisode, DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,7 @@
|
|||||||
<Compile Include="Datastore\Migration\140_add_alternative_titles_table.cs" />
|
<Compile Include="Datastore\Migration\140_add_alternative_titles_table.cs" />
|
||||||
<Compile Include="Datastore\Migration\141_fix_duplicate_alt_titles.cs" />
|
<Compile Include="Datastore\Migration\141_fix_duplicate_alt_titles.cs" />
|
||||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedAlternativeTitles.cs" />
|
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedAlternativeTitles.cs" />
|
||||||
|
<Compile Include="MediaFiles\EpisodeImport\Specifications\GrabbedReleaseQualitySpecification.cs" />
|
||||||
<Compile Include="MediaFiles\Events\MovieFileUpdatedEvent.cs" />
|
<Compile Include="MediaFiles\Events\MovieFileUpdatedEvent.cs" />
|
||||||
<Compile Include="Datastore\Migration\134_add_remux_qualities_for_the_wankers.cs" />
|
<Compile Include="Datastore\Migration\134_add_remux_qualities_for_the_wankers.cs" />
|
||||||
<Compile Include="Datastore\Migration\129_add_parsed_movie_info_to_pending_release.cs" />
|
<Compile Include="Datastore\Migration\129_add_parsed_movie_info_to_pending_release.cs" />
|
||||||
@ -1392,4 +1393,4 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user