mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-19 10:54:05 +02:00
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;
|
||||||
@ -298,7 +298,14 @@ namespace NzbDrone.Core.Download.Pending
|
|||||||
}
|
}
|
||||||
else
|
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
|
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;
|
||||||
remoteEpisode.Episodes = GetEpisodes(parsedEpisodeInfo, series, true, searchCriteria);
|
|
||||||
|
if (ValidateParsedEpisodeInfo.ValidateForSeriesType(parsedEpisodeInfo, series))
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
33
src/NzbDrone.Core/Parser/ValidateParsedEpisodeInfo.cs
Normal file
33
src/NzbDrone.Core/Parser/ValidateParsedEpisodeInfo.cs
Normal file
@ -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…
x
Reference in New Issue
Block a user