More restrictions when using download client title or folder name for parsing

Fixes #2663
This commit is contained in:
Mark McDowall 2018-08-27 21:35:03 -07:00
parent 3d7c59bc3b
commit ff9a9a5e4d
2 changed files with 41 additions and 2 deletions

View File

@ -105,5 +105,24 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(folderEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
}
[Test]
public void should_use_file_when_folder_is_absolute_and_file_is_not()
{
var fileEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
var folderEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.01");
var localEpisode = new LocalEpisode
{
FileEpisodeInfo = fileEpisodeInfo,
FolderEpisodeInfo = folderEpisodeInfo,
Path = @"C:\Test\Unsorted TV\Series.Title.101\Series.Title.S01E01.mkv".AsOsAgnostic(),
Series = _series
};
Subject.Aggregate(localEpisode, false);
Mocker.GetMock<IParsingService>()
.Verify(v => v.GetEpisodes(fileEpisodeInfo, _series, localEpisode.SceneSource, null), Times.Once());
}
}
}

View File

@ -30,11 +30,15 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
if (!otherFiles && !SceneChecker.IsSceneTitle(Path.GetFileNameWithoutExtension(localEpisode.Path)))
{
if (downloadClientEpisodeInfo != null && !downloadClientEpisodeInfo.FullSeason)
if (downloadClientEpisodeInfo != null &&
!downloadClientEpisodeInfo.FullSeason &&
PreferOtherEpisodeInfo(parsedEpisodeInfo, downloadClientEpisodeInfo))
{
parsedEpisodeInfo = localEpisode.DownloadClientEpisodeInfo;
}
else if (folderEpisodeInfo != null && !folderEpisodeInfo.FullSeason)
else if (folderEpisodeInfo != null &&
!folderEpisodeInfo.FullSeason &&
PreferOtherEpisodeInfo(parsedEpisodeInfo, folderEpisodeInfo))
{
parsedEpisodeInfo = localEpisode.FolderEpisodeInfo;
}
@ -68,5 +72,21 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
return new List<Episode>();
}
private bool PreferOtherEpisodeInfo(ParsedEpisodeInfo fileEpisodeInfo, ParsedEpisodeInfo otherEpisodeInfo)
{
if (fileEpisodeInfo == null)
{
return true;
}
// When the files episode info is not absolute prefer it over a parsed episode info that is absolute
if (!fileEpisodeInfo.IsAbsoluteNumbering && otherEpisodeInfo.IsAbsoluteNumbering)
{
return false;
}
return true;
}
}
}