mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Folder quality when file quality determined by its extension
Closes #603
This commit is contained in:
parent
bf217a7093
commit
a9444cef30
@ -84,8 +84,8 @@ private void GivenVideoFiles(IEnumerable<string> videoFiles)
|
||||
_videoFiles = videoFiles.ToList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
||||
.Returns(_videoFiles);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -180,21 +180,27 @@ public void should_use_file_quality_if_folder_quality_is_null()
|
||||
}
|
||||
|
||||
[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);
|
||||
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);
|
||||
}
|
||||
|
||||
[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);
|
||||
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);
|
||||
|
||||
|
@ -228,6 +228,24 @@ public void should_parse_quality_from_other_source(string qualityString, Quality
|
||||
}
|
||||
}
|
||||
|
||||
[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)
|
||||
{
|
||||
var result = QualityParser.ParseQuality(title);
|
||||
|
@ -181,9 +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 &&
|
||||
new QualityModelComparer(series.Profile).Compare(folderInfo.Quality, fileQuality) > 0)
|
||||
if (folderInfo != null && folderInfo.Quality.Quality != Quality.Unknown && fileQuality.QualitySource == QualitySource.Extension)
|
||||
{
|
||||
_logger.Debug("Using quality from folder: {0}", folderInfo.Quality);
|
||||
return folderInfo.Quality;
|
||||
|
@ -767,6 +767,7 @@
|
||||
<Compile Include="Profiles\Delay\DelayProfileTagInUseValidator.cs" />
|
||||
<Compile Include="Profiles\ProfileRepository.cs" />
|
||||
<Compile Include="ProgressMessaging\ProgressMessageContext.cs" />
|
||||
<Compile Include="Qualities\QualitySource.cs" />
|
||||
<Compile Include="Qualities\Revision.cs" />
|
||||
<Compile Include="RemotePathMappings\RemotePathMapping.cs" />
|
||||
<Compile Include="RemotePathMappings\RemotePathMappingRepository.cs" />
|
||||
|
@ -58,7 +58,6 @@ public static QualityModel ParseQuality(string name)
|
||||
var normalizedName = name.Replace('_', ' ').Trim().ToLower();
|
||||
var result = ParseQualityModifiers(name, normalizedName);
|
||||
|
||||
|
||||
if (RawHDRegex.IsMatch(normalizedName))
|
||||
{
|
||||
result.Quality = Quality.RAWHD;
|
||||
@ -276,6 +275,7 @@ public static QualityModel ParseQuality(string name)
|
||||
try
|
||||
{
|
||||
result.Quality = MediaFileExtensions.GetQualityForExtension(Path.GetExtension(name));
|
||||
result.QualitySource = QualitySource.Extension;
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.Qualities
|
||||
@ -7,6 +8,9 @@ public class QualityModel : IEmbeddedDocument, IEquatable<QualityModel>
|
||||
{
|
||||
public Quality Quality { get; set; }
|
||||
public Revision Revision { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public QualitySource QualitySource { get; set; }
|
||||
|
||||
public QualityModel()
|
||||
: this(Quality.Unknown, new Revision())
|
||||
|
9
src/NzbDrone.Core/Qualities/QualitySource.cs
Normal file
9
src/NzbDrone.Core/Qualities/QualitySource.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace NzbDrone.Core.Qualities
|
||||
{
|
||||
public enum QualitySource
|
||||
{
|
||||
Name,
|
||||
Extension,
|
||||
MediaInfo
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user