Fixed: Use runtime of series for sample checks instead of constant

pull/2/head
Mark McDowall 10 years ago
parent 16156611db
commit f8c002db9f

@ -24,6 +24,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
{ {
_series = Builder<Series>.CreateNew() _series = Builder<Series>.CreateNew()
.With(s => s.SeriesType = SeriesTypes.Standard) .With(s => s.SeriesType = SeriesTypes.Standard)
.With(s => s.Runtime = 30)
.Build(); .Build();
var episodes = Builder<Episode>.CreateListOfSize(1) var episodes = Builder<Episode>.CreateListOfSize(1)
@ -106,7 +107,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
[Test] [Test]
public void should_return_false_if_runtime_greater_than_than_minimum() public void should_return_false_if_runtime_greater_than_than_minimum()
{ {
GivenRuntime(120); GivenRuntime(600);
ShouldBeFalse(); ShouldBeFalse();
} }

@ -59,6 +59,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
try try
{ {
var runTime = _videoFileInfoReader.GetRunTime(path); var runTime = _videoFileInfoReader.GetRunTime(path);
var minimumRuntime = GetMinimumAllowedRuntime(series);
if (runTime.TotalMinutes.Equals(0)) if (runTime.TotalMinutes.Equals(0))
{ {
@ -66,9 +67,9 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
return true; 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; return true;
} }
} }
@ -103,5 +104,23 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
return false; 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;
}
} }
} }

@ -1,11 +1,5 @@
using System; using NLog;
using System.Collections.Generic;
using System.IO;
using NLog;
using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
{ {

Loading…
Cancel
Save