mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: Use runtime of series for sample checks instead of constant
This commit is contained in:
parent
16156611db
commit
f8c002db9f
@ -24,6 +24,7 @@ public void Setup()
|
||||
{
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesType = SeriesTypes.Standard)
|
||||
.With(s => s.Runtime = 30)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user