mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Quality Finder Tweaks
This commit is contained in:
parent
7fd391259c
commit
f2200f793d
@ -8,8 +8,34 @@ namespace NzbDrone.Core.Test.Qualities
|
||||
[TestFixture]
|
||||
public class QualityFinderFixture
|
||||
{
|
||||
[TestCase(Source.CAM, 480, Modifier.NONE)]
|
||||
[TestCase(Source.CAM, 1080, Modifier.NONE)]
|
||||
[TestCase(Source.CAM, 0, Modifier.NONE)]
|
||||
public void should_return_CAM(Source source, Resolution resolution, Modifier modifier)
|
||||
{
|
||||
QualityFinder.FindBySourceAndResolution(source, resolution, modifier).Should().Be(Quality.CAM);
|
||||
}
|
||||
|
||||
[TestCase(Source.CAM, 1080, Modifier.SCREENER)]
|
||||
[TestCase(Source.CAM, 0, Modifier.SCREENER)]
|
||||
public void should_return_Unknown(Source source, Resolution resolution, Modifier modifier)
|
||||
{
|
||||
QualityFinder.FindBySourceAndResolution(source, resolution, modifier).Should().Be(Quality.Unknown);
|
||||
}
|
||||
|
||||
[TestCase(Source.DVD, 480, Modifier.REMUX)]
|
||||
public void should_return_DVD_Remux(Source source, Resolution resolution, Modifier modifier)
|
||||
{
|
||||
QualityFinder.FindBySourceAndResolution(source, resolution, modifier).Should().Be(Quality.DVDR);
|
||||
}
|
||||
|
||||
[TestCase(Source.DVD, 480, Modifier.NONE)]
|
||||
public void should_return_DVD(Source source, Resolution resolution, Modifier modifier)
|
||||
{
|
||||
QualityFinder.FindBySourceAndResolution(source, resolution, modifier).Should().Be(Quality.DVD);
|
||||
}
|
||||
|
||||
[TestCase(Source.TV, 480, Modifier.NONE)]
|
||||
[TestCase(Source.UNKNOWN, 480, Modifier.NONE)]
|
||||
public void should_return_SDTV(Source source, Resolution resolution, Modifier modifier)
|
||||
{
|
||||
QualityFinder.FindBySourceAndResolution(source, resolution, modifier).Should().Be(Quality.SDTV);
|
||||
@ -30,7 +56,6 @@ public void should_return_HDTV_1080p(Source source, Resolution resolution, Modif
|
||||
}
|
||||
|
||||
[TestCase(Source.BLURAY, 720, Modifier.NONE)]
|
||||
[TestCase(Source.DVD, 720, Modifier.NONE)]
|
||||
public void should_return_Bluray720p(Source source, Resolution resolution, Modifier modifier)
|
||||
{
|
||||
QualityFinder.FindBySourceAndResolution(source, resolution, modifier).Should().Be(Quality.Bluray720p);
|
||||
|
@ -11,6 +11,7 @@ public static class QualityFinder
|
||||
|
||||
public static Quality FindBySourceAndResolution(Source source, Resolution resolution, Modifier modifer)
|
||||
{
|
||||
// Check for a perfect 3-way match
|
||||
var matchingQuality = Quality.All.SingleOrDefault(q => q.Source == source && q.Resolution == resolution && q.Modifier == modifer);
|
||||
|
||||
if (matchingQuality != null)
|
||||
@ -18,6 +19,27 @@ public static Quality FindBySourceAndResolution(Source source, Resolution resolu
|
||||
return matchingQuality;
|
||||
}
|
||||
|
||||
// Check for Source and Modifier Match for Qualities with Unknown Resolution
|
||||
var matchingQualitiesUnknownResolution = Quality.All.Where(q => q.Source == source && (q.Resolution == Resolution.Unknown) && q.Modifier == modifer && q != Quality.Unknown);
|
||||
|
||||
if (matchingQualitiesUnknownResolution.Any())
|
||||
{
|
||||
if (matchingQualitiesUnknownResolution.Count() == 1)
|
||||
{
|
||||
return matchingQualitiesUnknownResolution.First();
|
||||
}
|
||||
|
||||
foreach (var quality in matchingQualitiesUnknownResolution)
|
||||
{
|
||||
if (quality.Source >= source)
|
||||
{
|
||||
Logger.Warn("Unable to find exact quality for {0}, {1}, and {2}. Using {3} as fallback", source, resolution, modifer, quality);
|
||||
return quality;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check for Modifier match
|
||||
var matchingModifier = Quality.All.Where(q => q.Modifier == modifer);
|
||||
|
||||
var matchingResolution = matchingModifier.Where(q => q.Resolution == resolution)
|
||||
|
Loading…
Reference in New Issue
Block a user