Fixed: Folder quality when file quality determined by its extension

Closes #603
pull/3113/head
Mark McDowall 9 years ago
parent bf217a7093
commit a9444cef30

@ -180,21 +180,27 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
} }
[Test] [Test]
public void should_use_file_quality_if_folder_quality_is_lower_than_file_quality() public void should_use_file_quality_if_file_quality_was_determined_by_name()
{ {
GivenSpecifications(_pass1, _pass2, _pass3); GivenSpecifications(_pass1, _pass2, _pass3);
var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single()); var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single());
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo{Quality = new QualityModel(Quality.SDTV)}, true); var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo{Quality = new QualityModel(Quality.Bluray1080p)}, true);
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality); result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
} }
[Test] [Test]
public void should_use_folder_quality_when_it_is_greater_than_file_quality() public void should_use_folder_quality_when_file_quality_was_determined_by_the_extension()
{ {
GivenSpecifications(_pass1, _pass2, _pass3); GivenSpecifications(_pass1, _pass2, _pass3);
var expectedQuality = new QualityModel(Quality.Bluray1080p); GivenVideoFiles(new string[] { @"C:\Test\Unsorted\The.Office.S03E115.mkv".AsOsAgnostic() });
_localEpisode.Path = _videoFiles.Single();
_localEpisode.Quality.QualitySource = QualitySource.Extension;
_localEpisode.Quality.Quality = Quality.HDTV720p;
var expectedQuality = new QualityModel(Quality.SDTV);
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true); var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true);

@ -228,6 +228,24 @@ namespace NzbDrone.Core.Test.ParserTests
} }
} }
[TestCase("Saturday.Night.Live.Vintage.S10E09.Eddie.Murphy.The.Honeydrippers.1080i.UPSCALE.HDTV.DD5.1.MPEG2-zebra")]
[TestCase("Dexter - S01E01 - Title [HDTV-1080p]")]
[TestCase("[CR] Sailor Moon - 004 [480p][48CE2D0F]")]
[TestCase("White.Van.Man.2011.S02E01.WS.PDTV.x264-REPACK-TLA")]
public void should_parse_quality_from_name(string title)
{
QualityParser.ParseQuality(title).QualitySource.Should().Be(QualitySource.Name);
}
[TestCase("Revolution.S01E02.Chained.Heat.mkv")]
[TestCase("Dexter - S01E01 - Title.avi")]
[TestCase("the_x-files.9x18.sunshine_days.avi")]
[TestCase("[CR] Sailor Moon - 004 [48CE2D0F].avi")]
public void should_parse_quality_from_extension(string title)
{
QualityParser.ParseQuality(title).QualitySource.Should().Be(QualitySource.Extension);
}
private void ParseAndVerifyQuality(string title, Quality quality, bool proper) private void ParseAndVerifyQuality(string title, Quality quality, bool proper)
{ {
var result = QualityParser.ParseQuality(title); var result = QualityParser.ParseQuality(title);

@ -181,9 +181,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
private QualityModel GetQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Series series) private QualityModel GetQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Series series)
{ {
if (folderInfo != null && if (folderInfo != null && folderInfo.Quality.Quality != Quality.Unknown && fileQuality.QualitySource == QualitySource.Extension)
folderInfo.Quality.Quality != Quality.Unknown &&
new QualityModelComparer(series.Profile).Compare(folderInfo.Quality, fileQuality) > 0)
{ {
_logger.Debug("Using quality from folder: {0}", folderInfo.Quality); _logger.Debug("Using quality from folder: {0}", folderInfo.Quality);
return folderInfo.Quality; return folderInfo.Quality;

@ -767,6 +767,7 @@
<Compile Include="Profiles\Delay\DelayProfileTagInUseValidator.cs" /> <Compile Include="Profiles\Delay\DelayProfileTagInUseValidator.cs" />
<Compile Include="Profiles\ProfileRepository.cs" /> <Compile Include="Profiles\ProfileRepository.cs" />
<Compile Include="ProgressMessaging\ProgressMessageContext.cs" /> <Compile Include="ProgressMessaging\ProgressMessageContext.cs" />
<Compile Include="Qualities\QualitySource.cs" />
<Compile Include="Qualities\Revision.cs" /> <Compile Include="Qualities\Revision.cs" />
<Compile Include="RemotePathMappings\RemotePathMapping.cs" /> <Compile Include="RemotePathMappings\RemotePathMapping.cs" />
<Compile Include="RemotePathMappings\RemotePathMappingRepository.cs" /> <Compile Include="RemotePathMappings\RemotePathMappingRepository.cs" />

@ -58,7 +58,6 @@ namespace NzbDrone.Core.Parser
var normalizedName = name.Replace('_', ' ').Trim().ToLower(); var normalizedName = name.Replace('_', ' ').Trim().ToLower();
var result = ParseQualityModifiers(name, normalizedName); var result = ParseQualityModifiers(name, normalizedName);
if (RawHDRegex.IsMatch(normalizedName)) if (RawHDRegex.IsMatch(normalizedName))
{ {
result.Quality = Quality.RAWHD; result.Quality = Quality.RAWHD;
@ -276,6 +275,7 @@ namespace NzbDrone.Core.Parser
try try
{ {
result.Quality = MediaFileExtensions.GetQualityForExtension(Path.GetExtension(name)); result.Quality = MediaFileExtensions.GetQualityForExtension(Path.GetExtension(name));
result.QualitySource = QualitySource.Extension;
} }
catch (ArgumentException) catch (ArgumentException)
{ {

@ -1,4 +1,5 @@
using System; using System;
using Newtonsoft.Json;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Qualities namespace NzbDrone.Core.Qualities
@ -8,6 +9,9 @@ namespace NzbDrone.Core.Qualities
public Quality Quality { get; set; } public Quality Quality { get; set; }
public Revision Revision { get; set; } public Revision Revision { get; set; }
[JsonIgnore]
public QualitySource QualitySource { get; set; }
public QualityModel() public QualityModel()
: this(Quality.Unknown, new Revision()) : this(Quality.Unknown, new Revision())
{ {

@ -0,0 +1,9 @@
namespace NzbDrone.Core.Qualities
{
public enum QualitySource
{
Name,
Extension,
MediaInfo
}
}
Loading…
Cancel
Save