mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
New: Reject File if Sample Check Indeterminate
This commit is contained in:
parent
1c85bd96f8
commit
2390ab98fa
@ -256,8 +256,7 @@ public void should_delete_folder_if_files_were_imported_and_only_sample_files_re
|
||||
|
||||
Mocker.GetMock<IDetectSample>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Movie>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<bool>()))
|
||||
It.IsAny<string>()))
|
||||
.Returns(DetectSampleResult.Sample);
|
||||
|
||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||
@ -326,8 +325,7 @@ public void should_not_delete_if_there_is_large_rar_file()
|
||||
|
||||
Mocker.GetMock<IDetectSample>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Movie>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<bool>()))
|
||||
It.IsAny<string>()))
|
||||
.Returns(DetectSampleResult.Sample);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
@ -434,8 +432,7 @@ public void should_not_delete_if_no_files_were_imported()
|
||||
|
||||
Mocker.GetMock<IDetectSample>()
|
||||
.Setup(s => s.IsSample(It.IsAny<Movie>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<bool>()))
|
||||
It.IsAny<string>()))
|
||||
.Returns(DetectSampleResult.Sample);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -97,8 +97,7 @@ public void should_use_runtime()
|
||||
GivenRuntime(120);
|
||||
|
||||
Subject.IsSample(_localMovie.Movie,
|
||||
_localMovie.Path,
|
||||
false);
|
||||
_localMovie.Path);
|
||||
|
||||
Mocker.GetMock<IVideoFileInfoReader>().Verify(v => v.GetRunTime(It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
@ -154,8 +153,7 @@ public void should_return_indeterminate_if_mediainfo_result_is_null()
|
||||
.Returns((TimeSpan?)null);
|
||||
|
||||
Subject.IsSample(_localMovie.Movie,
|
||||
_localMovie.Path,
|
||||
false).Should().Be(DetectSampleResult.Indeterminate);
|
||||
_localMovie.Path).Should().Be(DetectSampleResult.Indeterminate);
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
@ -163,15 +161,13 @@ public void should_return_indeterminate_if_mediainfo_result_is_null()
|
||||
private void ShouldBeSample()
|
||||
{
|
||||
Subject.IsSample(_localMovie.Movie,
|
||||
_localMovie.Path,
|
||||
false).Should().Be(DetectSampleResult.Sample);
|
||||
_localMovie.Path).Should().Be(DetectSampleResult.Sample);
|
||||
}
|
||||
|
||||
private void ShouldBeNotSample()
|
||||
{
|
||||
Subject.IsSample(_localMovie.Movie,
|
||||
_localMovie.Path,
|
||||
false).Should().Be(DetectSampleResult.NotSample);
|
||||
_localMovie.Path).Should().Be(DetectSampleResult.NotSample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Movie movie)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_detectSample.IsSample(movie, videoFile, false) != DetectSampleResult.Sample)
|
||||
if (_detectSample.IsSample(movie, videoFile) != DetectSampleResult.Sample)
|
||||
{
|
||||
_logger.Warn("Non-sample file detected: [{0}]", videoFile);
|
||||
return false;
|
||||
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
|
||||
{
|
||||
public interface IDetectSample
|
||||
{
|
||||
DetectSampleResult IsSample(Movie movie, string path, bool isSpecial);
|
||||
DetectSampleResult IsSample(Movie movie, string path);
|
||||
}
|
||||
|
||||
public class DetectSample : IDetectSample
|
||||
@ -23,14 +23,8 @@ public DetectSample(IVideoFileInfoReader videoFileInfoReader, Logger logger)
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public DetectSampleResult IsSample(Movie movie, string path, bool isSpecial)
|
||||
public DetectSampleResult IsSample(Movie movie, string path)
|
||||
{
|
||||
if (isSpecial)
|
||||
{
|
||||
_logger.Debug("Special, skipping sample check");
|
||||
return DetectSampleResult.NotSample;
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
if (extension != null)
|
||||
@ -73,11 +67,11 @@ public DetectSampleResult IsSample(Movie movie, string path, bool isSpecial)
|
||||
|
||||
if (runTime.Value.TotalSeconds < minimumRuntime)
|
||||
{
|
||||
_logger.Debug("[{0}] appears to be a sample. Runtime: {1} seconds. Expected at least: {2} seconds", path, runTime, minimumRuntime);
|
||||
_logger.Debug("[{0}] appears to be a sample. Runtime: {1} seconds. Expected at least: {2} seconds", path, runTime.Value.TotalSeconds, minimumRuntime);
|
||||
return DetectSampleResult.Sample;
|
||||
}
|
||||
|
||||
_logger.Debug("Runtime is over 90 seconds");
|
||||
_logger.Debug("Runtime of {0} is more than {1} seconds, Not Sample", runTime.Value.TotalSeconds, minimumRuntime);
|
||||
return DetectSampleResult.NotSample;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie mo
|
||||
downloadClientItemInfo = _parsingService.EnhanceMovieInfo(downloadClientItemInfo);
|
||||
}
|
||||
|
||||
var nonSampleVideoFileCount = GetNonSampleVideoFileCount(newFiles, movie, downloadClientItemInfo, folderInfo);
|
||||
var nonSampleVideoFileCount = GetNonSampleVideoFileCount(newFiles, movie);
|
||||
|
||||
var decisions = new List<ImportDecision>();
|
||||
|
||||
@ -180,11 +180,11 @@ private Rejection EvaluateSpec(IImportDecisionEngineSpecification spec, LocalMov
|
||||
return null;
|
||||
}
|
||||
|
||||
private int GetNonSampleVideoFileCount(List<string> videoFiles, Movie movie, ParsedMovieInfo downloadClientItemInfo, ParsedMovieInfo folderInfo)
|
||||
private int GetNonSampleVideoFileCount(List<string> videoFiles, Movie movie)
|
||||
{
|
||||
return videoFiles.Count(file =>
|
||||
{
|
||||
var sample = _detectSample.IsSample(movie, file, false);
|
||||
var sample = _detectSample.IsSample(movie, file);
|
||||
|
||||
if (sample == DetectSampleResult.Sample)
|
||||
{
|
||||
|
@ -19,14 +19,22 @@ public NotSampleSpecification(IDetectSample detectSample,
|
||||
|
||||
public Decision IsSatisfiedBy(LocalMovie localMovie, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
var sample = _detectSample.IsSample(localMovie.Movie,
|
||||
localMovie.Path,
|
||||
false);
|
||||
if (localMovie.ExistingFile)
|
||||
{
|
||||
_logger.Debug("Existing file, skipping sample check");
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var sample = _detectSample.IsSample(localMovie.Movie, localMovie.Path);
|
||||
|
||||
if (sample == DetectSampleResult.Sample)
|
||||
{
|
||||
return Decision.Reject("Sample");
|
||||
}
|
||||
else if (sample == DetectSampleResult.Indeterminate)
|
||||
{
|
||||
return Decision.Reject("Unable to determine if file is a sample");
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user