2013-07-19 03:47:55 +00:00
|
|
|
|
using NLog;
|
2013-07-06 21:47:49 +00:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
|
|
|
|
{
|
|
|
|
|
public class NotSampleSpecification : IImportDecisionEngineSpecification
|
|
|
|
|
{
|
|
|
|
|
private readonly IVideoFileInfoReader _videoFileInfoReader;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
2013-07-16 06:43:45 +00:00
|
|
|
|
public NotSampleSpecification(IVideoFileInfoReader videoFileInfoReader,
|
|
|
|
|
Logger logger)
|
2013-07-06 21:47:49 +00:00
|
|
|
|
{
|
|
|
|
|
_videoFileInfoReader = videoFileInfoReader;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-16 06:43:45 +00:00
|
|
|
|
public static long SampleSizeLimit
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return 70.Megabytes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-06 21:47:49 +00:00
|
|
|
|
public string RejectionReason { get { return "Sample"; } }
|
|
|
|
|
|
|
|
|
|
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
|
|
|
|
{
|
|
|
|
|
if (localEpisode.Series.SeriesType == SeriesTypes.Daily)
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Daily Series, skipping sample check");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (localEpisode.SeasonNumber == 0)
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Special, skipping sample check");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-19 05:05:07 +00:00
|
|
|
|
if (localEpisode.Size > SampleSizeLimit)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-06 21:47:49 +00:00
|
|
|
|
var runTime = _videoFileInfoReader.GetRunTime(localEpisode.Path);
|
|
|
|
|
|
2013-07-19 05:05:07 +00:00
|
|
|
|
if (runTime.TotalMinutes < 3)
|
2013-07-06 21:47:49 +00:00
|
|
|
|
{
|
2013-07-19 05:05:07 +00:00
|
|
|
|
_logger.Trace("[{0}] appears to be a sample. Size: {1} Runtime: {2}", localEpisode.Path, localEpisode.Size, runTime);
|
2013-07-06 21:47:49 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|