diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs index e15234f93..e5e3e15f8 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/SampleServiceFixture.cs @@ -24,6 +24,7 @@ public void Setup() { _series = Builder.CreateNew() .With(s => s.SeriesType = SeriesTypes.Standard) + .With(s => s.Runtime = 30) .Build(); var episodes = Builder.CreateListOfSize(1) @@ -106,7 +107,7 @@ public void should_return_true_if_runtime_is_less_than_minimum() [Test] public void should_return_false_if_runtime_greater_than_than_minimum() { - GivenRuntime(120); + GivenRuntime(600); ShouldBeFalse(); } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/SampleService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/SampleService.cs index 0515a0aa6..66f16f937 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/SampleService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/SampleService.cs @@ -59,6 +59,7 @@ public bool IsSample(Series series, QualityModel quality, string path, long size try { var runTime = _videoFileInfoReader.GetRunTime(path); + var minimumRuntime = GetMinimumAllowedRuntime(series); if (runTime.TotalMinutes.Equals(0)) { @@ -66,9 +67,9 @@ public bool IsSample(Series series, QualityModel quality, string path, long size return true; } - if (runTime.TotalSeconds < 90) + if (runTime.TotalSeconds < minimumRuntime) { - _logger.Debug("[{0}] appears to be a sample. Size: {1} Runtime: {2}", path, size, runTime); + _logger.Debug("[{0}] appears to be a sample. Runtime: {1} seconds. Expected at least: {1} seconds", path, runTime, minimumRuntime); return true; } } @@ -103,5 +104,23 @@ private bool CheckSize(long size, QualityModel quality) return false; } + + private int GetMinimumAllowedRuntime(Series series) + { + //Webisodes - 90 seconds + if (series.Runtime <= 5) + { + return 90; + } + + //30 minute episodes - 5 minutes + if (series.Runtime <= 30) + { + return 300; + } + + //60 minute episodes - 10 minutes + return 600; + } } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs index 4101ba986..7d32566f8 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/NotSampleSpecification.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using NLog; -using NzbDrone.Core.MediaFiles.MediaInfo; +using NLog; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Qualities; -using NzbDrone.Core.Tv; namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications {