From 47e7805cf9233e2e868b2cd8a7841ba9a863bb62 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 8 Aug 2013 18:50:11 -0700 Subject: [PATCH] Skip sample check for .flv files, also log error for runtime 0 --- .../NotSampleSpecificationFixture.cs | 20 ++++++++++++++++++- .../Specifications/NotSampleSpecification.cs | 16 ++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotSampleSpecificationFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotSampleSpecificationFixture.cs index 8d7afcd1f..f89cfa48d 100644 --- a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotSampleSpecificationFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotSampleSpecificationFixture.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests { @@ -120,10 +121,27 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue(); - Mocker.GetMock().Verify(c => c.GetRunTime(It.IsAny()), Times.Never()); } + [Test] + public void should_log_error_if_run_time_is_0_and_under_sample_size() + { + WithFileSize(40.Megabytes()); + WithLength(0); + Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse(); + ExceptionVerification.ExpectedErrors(1); + } + + [Test] + public void should_skip_check_for_flv_file() + { + _localEpisode.Path = @"C:\Test\some.show.s01e01.flv"; + + Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue(); + + Mocker.GetMock().Verify(c => c.GetRunTime(It.IsAny()), Times.Never()); + } } } diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs index 746d3dc1c..51561b005 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs @@ -1,4 +1,6 @@ -using NLog; +using System; +using System.IO; +using NLog; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Tv; @@ -41,6 +43,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications return true; } + if (Path.GetExtension(localEpisode.Path).Equals(".flv", StringComparison.InvariantCultureIgnoreCase)) + { + _logger.Trace("Skipping smaple check for .flv file"); + return true; + } + if (localEpisode.Size > SampleSizeLimit) { return true; @@ -48,6 +56,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications var runTime = _videoFileInfoReader.GetRunTime(localEpisode.Path); + if (runTime.TotalMinutes.Equals(0)) + { + _logger.Error("[{0}] has a runtime of 0, is it a valid video file?", localEpisode); + return false; + } + if (runTime.TotalMinutes < 3) { _logger.Trace("[{0}] appears to be a sample. Size: {1} Runtime: {2}", localEpisode.Path, localEpisode.Size, runTime);