diff --git a/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs index c36d41c50..1826985c0 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/DownloadedMoviesImportServiceFixture.cs @@ -256,8 +256,7 @@ namespace NzbDrone.Core.Test.MediaFiles Mocker.GetMock() .Setup(s => s.IsSample(It.IsAny(), - It.IsAny(), - It.IsAny())) + It.IsAny())) .Returns(DetectSampleResult.Sample); Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory)); @@ -326,8 +325,7 @@ namespace NzbDrone.Core.Test.MediaFiles Mocker.GetMock() .Setup(s => s.IsSample(It.IsAny(), - It.IsAny(), - It.IsAny())) + It.IsAny())) .Returns(DetectSampleResult.Sample); Mocker.GetMock() @@ -434,8 +432,7 @@ namespace NzbDrone.Core.Test.MediaFiles Mocker.GetMock() .Setup(s => s.IsSample(It.IsAny(), - It.IsAny(), - It.IsAny())) + It.IsAny())) .Returns(DetectSampleResult.Sample); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/MediaFiles/MovieImport/DetectSampleFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/DetectSampleFixture.cs index 71eaa3e1f..8975a164c 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MovieImport/DetectSampleFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MovieImport/DetectSampleFixture.cs @@ -97,8 +97,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport GivenRuntime(120); Subject.IsSample(_localMovie.Movie, - _localMovie.Path, - false); + _localMovie.Path); Mocker.GetMock().Verify(v => v.GetRunTime(It.IsAny()), Times.Once()); } @@ -154,8 +153,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport .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 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport 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); } } } diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs index 2a3947728..1fd8d4dfc 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs @@ -131,7 +131,7 @@ namespace NzbDrone.Core.MediaFiles 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; diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs index 88f404c19..9a948af1f 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/DetectSample.cs @@ -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 @@ namespace NzbDrone.Core.MediaFiles.MovieImport _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 @@ namespace NzbDrone.Core.MediaFiles.MovieImport 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; } diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs index b252dccc6..3382b6128 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs @@ -71,7 +71,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport downloadClientItemInfo = _parsingService.EnhanceMovieInfo(downloadClientItemInfo); } - var nonSampleVideoFileCount = GetNonSampleVideoFileCount(newFiles, movie, downloadClientItemInfo, folderInfo); + var nonSampleVideoFileCount = GetNonSampleVideoFileCount(newFiles, movie); var decisions = new List(); @@ -180,11 +180,11 @@ namespace NzbDrone.Core.MediaFiles.MovieImport return null; } - private int GetNonSampleVideoFileCount(List videoFiles, Movie movie, ParsedMovieInfo downloadClientItemInfo, ParsedMovieInfo folderInfo) + private int GetNonSampleVideoFileCount(List videoFiles, Movie movie) { return videoFiles.Count(file => { - var sample = _detectSample.IsSample(movie, file, false); + var sample = _detectSample.IsSample(movie, file); if (sample == DetectSampleResult.Sample) { diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs index 89fda7fb0..2cddda5fd 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Specifications/NotSampleSpecification.cs @@ -19,14 +19,22 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Specifications 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(); }