Fixed: Suppress warnings for daily style extra files

Fixes #2503
pull/2536/head
Mark McDowall 7 years ago
parent 2b3956cb60
commit aba8abb176

@ -333,6 +333,7 @@
<Compile Include="OrganizerTests\FileNameBuilderTests\MultiEpisodeFixture.cs" />
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheFixture.cs" />
<Compile Include="ParserTests\MiniSeriesEpisodeParserFixture.cs" />
<Compile Include="ParserTests\ValidateParsedEpisodeInfoFixture.cs" />
<Compile Include="Qualities\RevisionComparableFixture.cs" />
<Compile Include="QueueTests\QueueServiceFixture.cs" />
<Compile Include="RemotePathMappingsTests\RemotePathMappingServiceFixture.cs" />

@ -0,0 +1,73 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
public class ValidateParsedEpisodeInfoFixture : CoreTest
{
private ParsedEpisodeInfo _parsedEpisodeInfo;
private Series _series;
[SetUp]
public void Setup()
{
_parsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew()
.With(p => p.AirDate = null)
.Build();
_series = Builder<Series>.CreateNew()
.With(s => s.SeriesType = SeriesTypes.Standard)
.Build();
}
private void GivenDailyParsedEpisodeInfo()
{
_parsedEpisodeInfo.AirDate = "2018-05-21";
}
private void GivenDailySeries()
{
_series.SeriesType = SeriesTypes.Daily;
}
[Test]
public void should_return_true_if_episode_info_is_not_daily()
{
ValidateParsedEpisodeInfo.ValidateForSeriesType(_parsedEpisodeInfo, _series).Should().BeTrue();
}
[Test]
public void should_return_true_if_episode_info_is_daily_for_daily_series()
{
GivenDailyParsedEpisodeInfo();
GivenDailySeries();
ValidateParsedEpisodeInfo.ValidateForSeriesType(_parsedEpisodeInfo, _series).Should().BeTrue();
}
[Test]
public void should_return_false_if_episode_info_is_daily_for_standard_series()
{
GivenDailyParsedEpisodeInfo();
ValidateParsedEpisodeInfo.ValidateForSeriesType(_parsedEpisodeInfo, _series).Should().BeFalse();
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void should_not_log_warning_if_warnIfInvalid_is_false()
{
GivenDailyParsedEpisodeInfo();
ValidateParsedEpisodeInfo.ValidateForSeriesType(_parsedEpisodeInfo, _series, false);
ExceptionVerification.ExpectedWarns(0);
}
}
}

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Marr.Data;
@ -298,7 +298,14 @@ namespace NzbDrone.Core.Download.Pending
}
else
{
episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true);
if (ValidateParsedEpisodeInfo.ValidateForSeriesType(release.ParsedEpisodeInfo, series))
{
episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true);
}
else
{
episodes = new List<Episode>();
}
}
release.RemoteEpisode = new RemoteEpisode

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.IO;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
{
@ -15,9 +17,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
public LocalEpisode Aggregate(LocalEpisode localEpisode, bool otherFiles)
{
var bestEpisodeInfoForEpisodes = GetBestEpisodeInfo(localEpisode, otherFiles);
localEpisode.Episodes = _parsingService.GetEpisodes(bestEpisodeInfoForEpisodes, localEpisode.Series, localEpisode.SceneSource);
localEpisode.Episodes = GetEpisodes(localEpisode, otherFiles);
return localEpisode;
}
@ -50,5 +50,18 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
return parsedEpisodeInfo;
}
private List<Episode> GetEpisodes(LocalEpisode localEpisode, bool otherFiles)
{
var bestEpisodeInfoForEpisodes = GetBestEpisodeInfo(localEpisode, otherFiles);
var isMediaFile = MediaFileExtensions.Extensions.Contains(Path.GetExtension(localEpisode.Path));
if (ValidateParsedEpisodeInfo.ValidateForSeriesType(bestEpisodeInfoForEpisodes, localEpisode.Series, isMediaFile))
{
return _parsingService.GetEpisodes(bestEpisodeInfoForEpisodes, localEpisode.Series, localEpisode.SceneSource);
}
return new List<Episode>();
}
}
}

@ -963,6 +963,7 @@
<Compile Include="Parser\IsoLanguage.cs" />
<Compile Include="Parser\IsoLanguages.cs" />
<Compile Include="Parser\LanguageParser.cs" />
<Compile Include="Parser\ValidateParsedEpisodeInfo.cs" />
<Compile Include="Profiles\Delay\DelayProfile.cs" />
<Compile Include="Profiles\Delay\DelayProfileService.cs" />
<Compile Include="Profiles\Delay\DelayProfileTagInUseValidator.cs" />

@ -79,7 +79,11 @@ namespace NzbDrone.Core.Parser
}
remoteEpisode.Series = series;
remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria);
if (ValidateParsedEpisodeInfo.ValidateForSeriesType(parsedEpisodeInfo, series))
{
remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria);
}
return remoteEpisode;
}
@ -103,12 +107,6 @@ namespace NzbDrone.Core.Parser
if (parsedEpisodeInfo.IsDaily)
{
if (series.SeriesType == SeriesTypes.Standard)
{
_logger.Warn("Found daily-style episode for non-daily series: {0}.", series);
return new List<Episode>();
}
var episodeInfo = GetDailyEpisode(series, parsedEpisodeInfo.AirDate, searchCriteria);
if (episodeInfo != null)

@ -0,0 +1,33 @@
using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Parser
{
public static class ValidateParsedEpisodeInfo
{
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(ValidateParsedEpisodeInfo));
public static bool ValidateForSeriesType(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool warnIfInvalid = true)
{
if (parsedEpisodeInfo.IsDaily && series.SeriesType == SeriesTypes.Standard)
{
var message = $"Found daily-style episode for non-daily series: {series}";
if (warnIfInvalid)
{
Logger.Warn(message);
}
else
{
Logger.Debug(message);
}
return false;
}
return true;
}
}
}
Loading…
Cancel
Save