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\MultiEpisodeFixture.cs" />
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheFixture.cs" /> <Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheFixture.cs" />
<Compile Include="ParserTests\MiniSeriesEpisodeParserFixture.cs" /> <Compile Include="ParserTests\MiniSeriesEpisodeParserFixture.cs" />
<Compile Include="ParserTests\ValidateParsedEpisodeInfoFixture.cs" />
<Compile Include="Qualities\RevisionComparableFixture.cs" /> <Compile Include="Qualities\RevisionComparableFixture.cs" />
<Compile Include="QueueTests\QueueServiceFixture.cs" /> <Compile Include="QueueTests\QueueServiceFixture.cs" />
<Compile Include="RemotePathMappingsTests\RemotePathMappingServiceFixture.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.Collections.Generic;
using System.Linq; using System.Linq;
using Marr.Data; using Marr.Data;
@ -297,9 +297,16 @@ namespace NzbDrone.Core.Download.Pending
episodes = knownRemoteEpisode.Episodes; episodes = knownRemoteEpisode.Episodes;
} }
else else
{
if (ValidateParsedEpisodeInfo.ValidateForSeriesType(release.ParsedEpisodeInfo, series))
{ {
episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true); episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true);
} }
else
{
episodes = new List<Episode>();
}
}
release.RemoteEpisode = new RemoteEpisode release.RemoteEpisode = new RemoteEpisode
{ {

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.IO; using System.IO;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators 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) public LocalEpisode Aggregate(LocalEpisode localEpisode, bool otherFiles)
{ {
var bestEpisodeInfoForEpisodes = GetBestEpisodeInfo(localEpisode, otherFiles); localEpisode.Episodes = GetEpisodes(localEpisode, otherFiles);
localEpisode.Episodes = _parsingService.GetEpisodes(bestEpisodeInfoForEpisodes, localEpisode.Series, localEpisode.SceneSource);
return localEpisode; return localEpisode;
} }
@ -50,5 +50,18 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
return parsedEpisodeInfo; 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\IsoLanguage.cs" />
<Compile Include="Parser\IsoLanguages.cs" /> <Compile Include="Parser\IsoLanguages.cs" />
<Compile Include="Parser\LanguageParser.cs" /> <Compile Include="Parser\LanguageParser.cs" />
<Compile Include="Parser\ValidateParsedEpisodeInfo.cs" />
<Compile Include="Profiles\Delay\DelayProfile.cs" /> <Compile Include="Profiles\Delay\DelayProfile.cs" />
<Compile Include="Profiles\Delay\DelayProfileService.cs" /> <Compile Include="Profiles\Delay\DelayProfileService.cs" />
<Compile Include="Profiles\Delay\DelayProfileTagInUseValidator.cs" /> <Compile Include="Profiles\Delay\DelayProfileTagInUseValidator.cs" />

@ -79,7 +79,11 @@ namespace NzbDrone.Core.Parser
} }
remoteEpisode.Series = series; remoteEpisode.Series = series;
if (ValidateParsedEpisodeInfo.ValidateForSeriesType(parsedEpisodeInfo, series))
{
remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria); remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria);
}
return remoteEpisode; return remoteEpisode;
} }
@ -103,12 +107,6 @@ namespace NzbDrone.Core.Parser
if (parsedEpisodeInfo.IsDaily) 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); var episodeInfo = GetDailyEpisode(series, parsedEpisodeInfo.AirDate, searchCriteria);
if (episodeInfo != null) 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