No longer checking history when doing a manual search.
This commit is contained in:
parent
926bdef527
commit
d1262f1ced
|
@ -274,5 +274,38 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
|
|
||||||
Assert.AreEqual(excpected, result);
|
Assert.AreEqual(excpected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IsQualityNeeded_file_should_skip_history_check_for_manual_search()
|
||||||
|
{
|
||||||
|
WithStrictMocker();
|
||||||
|
|
||||||
|
parseResultSingle.Series.QualityProfile = sdProfile;
|
||||||
|
parseResultSingle.Quality.QualityType = QualityTypes.DVD;
|
||||||
|
|
||||||
|
Mocker.GetMock<HistoryProvider>()
|
||||||
|
.Setup(p => p.GetBestQualityInHistory(episode.EpisodeId))
|
||||||
|
.Returns<Quality>(null);
|
||||||
|
|
||||||
|
Mocker.GetMock<EpisodeProvider>()
|
||||||
|
.Setup(p => p.GetEpisodesByParseResult(parseResultSingle, true))
|
||||||
|
.Returns(new List<Episode> { episode });
|
||||||
|
|
||||||
|
Mocker.GetMock<EpisodeProvider>()
|
||||||
|
.Setup(p => p.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||||
|
.Returns(false);
|
||||||
|
|
||||||
|
Mocker.GetMock<QualityTypeProvider>()
|
||||||
|
.Setup(s => s.Get(It.IsAny<int>()))
|
||||||
|
.Returns(new QualityType { MaxSize = 100, MinSize = 0 });
|
||||||
|
|
||||||
|
episode.EpisodeFile.Quality = QualityTypes.SDTV;
|
||||||
|
//Act
|
||||||
|
bool result = Mocker.Resolve<InventoryProvider>().IsQualityNeeded(parseResultSingle, true);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().BeTrue();
|
||||||
|
Mocker.Verify<HistoryProvider>(c => c.GetBestQualityInHistory(It.IsAny<int>()), Times.Never());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -75,14 +75,14 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
private void WithQualityNeeded()
|
private void WithQualityNeeded()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<InventoryProvider>()
|
Mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>()))
|
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithQualityNotNeeded()
|
private void WithQualityNotNeeded()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<InventoryProvider>()
|
Mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>()))
|
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
WithSuccessfulDownload();
|
WithSuccessfulDownload();
|
||||||
|
|
||||||
Mocker.GetMock<InventoryProvider>()
|
Mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
|
.Setup(s => s.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p), true))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().BeTrue();
|
result.Should().BeTrue();
|
||||||
|
|
||||||
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true),
|
||||||
Times.Once());
|
Times.Once());
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
||||||
Times.Once());
|
Times.Once());
|
||||||
|
@ -134,7 +134,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().BeFalse();
|
result.Should().BeFalse();
|
||||||
|
|
||||||
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true),
|
||||||
Times.Exactly(5));
|
Times.Exactly(5));
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
||||||
Times.Never());
|
Times.Never());
|
||||||
|
|
|
@ -75,14 +75,14 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
private void WithQualityNeeded()
|
private void WithQualityNeeded()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<InventoryProvider>()
|
Mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>()))
|
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithQualityNotNeeded()
|
private void WithQualityNotNeeded()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<InventoryProvider>()
|
Mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>()))
|
.Setup(s => s.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
WithSuccessfulDownload();
|
WithSuccessfulDownload();
|
||||||
|
|
||||||
Mocker.GetMock<InventoryProvider>()
|
Mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(s => s.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
|
.Setup(s => s.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p), true))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
result.Should().HaveCount(1);
|
result.Should().HaveCount(1);
|
||||||
result.First().Should().Be(1);
|
result.First().Should().Be(1);
|
||||||
|
|
||||||
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true),
|
||||||
Times.Once());
|
Times.Once());
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
||||||
Times.Once());
|
Times.Once());
|
||||||
|
@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||||
//Assert
|
//Assert
|
||||||
result.Should().HaveCount(0);
|
result.Should().HaveCount(0);
|
||||||
|
|
||||||
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>(), true),
|
||||||
Times.Exactly(5));
|
Times.Exactly(5));
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
||||||
Times.Never());
|
Times.Never());
|
||||||
|
|
|
@ -68,10 +68,11 @@ namespace NzbDrone.Core.Providers
|
||||||
/// Comprehensive check on whether or not this episode is needed.
|
/// Comprehensive check on whether or not this episode is needed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name = "parsedReport">Episode that needs to be checked</param>
|
/// <param name = "parsedReport">Episode that needs to be checked</param>
|
||||||
|
/// <param name="manualSearch">False unless called by a manual search job</param>
|
||||||
/// <returns>Whether or not the file quality meets the requirements </returns>
|
/// <returns>Whether or not the file quality meets the requirements </returns>
|
||||||
/// <remarks>for multi episode files, all episodes need to meet the requirement
|
/// <remarks>for multi episode files, all episodes need to meet the requirement
|
||||||
/// before the report is downloaded</remarks>
|
/// before the report is downloaded</remarks>
|
||||||
public virtual bool IsQualityNeeded(EpisodeParseResult parsedReport)
|
public virtual bool IsQualityNeeded(EpisodeParseResult parsedReport, bool manualSearch = false)
|
||||||
{
|
{
|
||||||
Logger.Trace("Checking if report meets quality requirements. {0}", parsedReport.Quality);
|
Logger.Trace("Checking if report meets quality requirements. {0}", parsedReport.Quality);
|
||||||
if (!parsedReport.Series.QualityProfile.Allowed.Contains(parsedReport.Quality.QualityType))
|
if (!parsedReport.Series.QualityProfile.Allowed.Contains(parsedReport.Quality.QualityType))
|
||||||
|
@ -96,13 +97,16 @@ namespace NzbDrone.Core.Providers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Checking History
|
//Checking History (If not a manual search)
|
||||||
var bestQualityInHistory = _historyProvider.GetBestQualityInHistory(episode.EpisodeId);
|
if (!manualSearch)
|
||||||
if (bestQualityInHistory != null)
|
|
||||||
{
|
{
|
||||||
Logger.Trace("Comparing history quality with report. History is {0}", bestQualityInHistory);
|
var bestQualityInHistory = _historyProvider.GetBestQualityInHistory(episode.EpisodeId);
|
||||||
if (!IsUpgrade(bestQualityInHistory, parsedReport.Quality, cutoff))
|
if(bestQualityInHistory != null)
|
||||||
return false;
|
{
|
||||||
|
Logger.Trace("Comparing history quality with report. History is {0}", bestQualityInHistory);
|
||||||
|
if(!IsUpgrade(bestQualityInHistory, parsedReport.Quality, cutoff))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ namespace NzbDrone.Core.Providers
|
||||||
if (successes.Intersect(episodeParseResult.EpisodeNumbers).Count() > 0)
|
if (successes.Intersect(episodeParseResult.EpisodeNumbers).Count() > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
if (_inventoryProvider.IsQualityNeeded(episodeParseResult, true))
|
||||||
{
|
{
|
||||||
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||||
try
|
try
|
||||||
|
@ -286,7 +286,7 @@ namespace NzbDrone.Core.Providers
|
||||||
if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value.Date != airDate.Date)
|
if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value.Date != airDate.Date)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_inventoryProvider.IsQualityNeeded(episodeParseResult))
|
if (_inventoryProvider.IsQualityNeeded(episodeParseResult, true))
|
||||||
{
|
{
|
||||||
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
Logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue