diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodesFixture.cs index fcef3de8a..de779bb23 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodesFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodesFixture.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; +using FluentAssertions.Equivalency; using Moq; using NUnit.Framework; using NzbDrone.Common.Extensions; @@ -28,6 +29,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators new Mock() }; + Mocker.GetMock() + .Setup(s => s.GetEpisodes(It.IsAny(), _series, It.IsAny(), null)) + .Returns(Builder.CreateListOfSize(1).BuildList()); + Mocker.SetConstant(augmenters.Select(c => c.Object)); } @@ -140,6 +145,10 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators Series = _series }; + Mocker.GetMock() + .Setup(s => s.GetEpisodes(fileEpisodeInfo, _series, It.IsAny(), null)) + .Returns(new List()); + Mocker.GetMock() .Setup(s => s.ParseSpecialEpisodeTitle(fileEpisodeInfo, It.IsAny(), _series)) .Returns(specialEpisodeInfo); diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodes.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodes.cs index c9f3c39e5..6f92354e2 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodes.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateEpisodes.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Download; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; @@ -45,20 +46,22 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators } } - if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode) + if (parsedEpisodeInfo == null) { - var title = Path.GetFileNameWithoutExtension(localEpisode.Path); - var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(parsedEpisodeInfo, title, localEpisode.Series); - - if (specialEpisodeInfo != null) - { - parsedEpisodeInfo = specialEpisodeInfo; - } + parsedEpisodeInfo = GetSpecialEpisodeInfo(localEpisode, parsedEpisodeInfo); } return parsedEpisodeInfo; } + private ParsedEpisodeInfo GetSpecialEpisodeInfo(LocalEpisode localEpisode, ParsedEpisodeInfo parsedEpisodeInfo) + { + var title = Path.GetFileNameWithoutExtension(localEpisode.Path); + var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(parsedEpisodeInfo, title, localEpisode.Series); + + return specialEpisodeInfo; + } + private List GetEpisodes(LocalEpisode localEpisode) { var bestEpisodeInfoForEpisodes = GetBestEpisodeInfo(localEpisode); @@ -71,7 +74,16 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators if (ValidateParsedEpisodeInfo.ValidateForSeriesType(bestEpisodeInfoForEpisodes, localEpisode.Series, isMediaFile)) { - return _parsingService.GetEpisodes(bestEpisodeInfoForEpisodes, localEpisode.Series, localEpisode.SceneSource); + var episodes = _parsingService.GetEpisodes(bestEpisodeInfoForEpisodes, localEpisode.Series, localEpisode.SceneSource); + + if (episodes.Empty() && bestEpisodeInfoForEpisodes.IsPossibleSpecialEpisode) + { + var parsedEpisodeInfo = GetSpecialEpisodeInfo(localEpisode, bestEpisodeInfoForEpisodes); + + episodes = _parsingService.GetEpisodes(parsedEpisodeInfo, localEpisode.Series, localEpisode.SceneSource); + } + + return episodes; } return new List();