1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-29 03:15:19 +00:00

Fixed: Use folder quality when better than file quality (regression)

Closes #1022
This commit is contained in:
Mark McDowall 2016-01-04 23:11:06 -08:00
parent 376481eda5
commit b62ef0c40c
2 changed files with 42 additions and 1 deletions

View file

@ -207,6 +207,22 @@ public void should_use_folder_quality_when_file_quality_was_determined_by_the_ex
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
}
[Test]
public void should_use_folder_quality_when_greater_than_file_quality()
{
GivenSpecifications(_pass1, _pass2, _pass3);
GivenVideoFiles(new string[] { @"C:\Test\Unsorted\The.Office.S03E115.mkv".AsOsAgnostic() });
_localEpisode.Path = _videoFiles.Single();
_localEpisode.Quality.Quality = Quality.HDTV720p;
var expectedQuality = new QualityModel(Quality.Bluray720p);
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true);
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
}
[Test]
public void should_not_throw_if_episodes_are_not_found()
{

View file

@ -181,7 +181,7 @@ private bool ShouldUseFolderName(List<string> videoFiles, Series series, ParsedE
private QualityModel GetQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Series series)
{
if (folderInfo != null && folderInfo.Quality.Quality != Quality.Unknown && fileQuality.QualitySource == QualitySource.Extension)
if (UseFolderQuality(folderInfo, fileQuality, series))
{
_logger.Debug("Using quality from folder: {0}", folderInfo.Quality);
return folderInfo.Quality;
@ -189,5 +189,30 @@ private QualityModel GetQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQ
return fileQuality;
}
private bool UseFolderQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Series series)
{
if (folderInfo == null)
{
return false;
}
if (folderInfo.Quality.Quality == Quality.Unknown)
{
return false;
}
if (fileQuality.QualitySource == QualitySource.Extension)
{
return true;
}
if (new QualityModelComparer(series.Profile).Compare(folderInfo.Quality, fileQuality) > 0)
{
return true;
}
return false;
}
}
}