mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
cleaned up episode search
This commit is contained in:
parent
02d842a2b2
commit
ef5f565a4d
@ -2,7 +2,7 @@
|
|||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
|
|
||||||
namespace NzbDrone.Api.RootFolders
|
namespace NzbDrone.Api.RootFolders
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -1,181 +1,53 @@
|
|||||||
// ReSharper disable RedundantUsingDirective
|
using System.ComponentModel;
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using FizzWare.NBuilder;
|
|
||||||
using FluentAssertions;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
public class AllowedDownloadSpecificationFixture : CoreTest
|
public class AllowedDownloadSpecificationFixture : CoreTest
|
||||||
{
|
{
|
||||||
private AllowedDownloadSpecification spec;
|
|
||||||
private EpisodeParseResult parseResult;
|
private EpisodeParseResult parseResult;
|
||||||
|
|
||||||
|
private Mock<IFetchableSpecification> pass1;
|
||||||
|
private Mock<IFetchableSpecification> pass2;
|
||||||
|
private Mock<IFetchableSpecification> pass3;
|
||||||
|
|
||||||
|
private Mock<IFetchableSpecification> fail1;
|
||||||
|
private Mock<IFetchableSpecification> fail2;
|
||||||
|
private Mock<IFetchableSpecification> fail3;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
spec = Mocker.Resolve<AllowedDownloadSpecification>();
|
pass1 = new Mock<IFetchableSpecification>();
|
||||||
|
pass2 = new Mock<IFetchableSpecification>();
|
||||||
|
pass3 = new Mock<IFetchableSpecification>();
|
||||||
|
|
||||||
|
fail1 = new Mock<IFetchableSpecification>();
|
||||||
|
fail2 = new Mock<IFetchableSpecification>();
|
||||||
|
fail3 = new Mock<IFetchableSpecification>();
|
||||||
|
|
||||||
|
pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(true);
|
||||||
|
|
||||||
|
fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(false);
|
||||||
|
fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(false);
|
||||||
|
fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(false);
|
||||||
|
|
||||||
parseResult = new EpisodeParseResult();
|
parseResult = new EpisodeParseResult();
|
||||||
|
|
||||||
Mocker.GetMock<QualityAllowedByProfileSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Mocker.GetMock<AcceptableSizeSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Mocker.GetMock<UpgradeDiskSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Mocker.GetMock<NotInQueueSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
|
|
||||||
Mocker.GetMock<RetentionSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Mocker.GetMock<AllowedReleaseGroupSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Mocker.GetMock<CustomStartDateSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
|
|
||||||
Mocker.GetMock<LanguageSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithProfileNotAllowed()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<QualityAllowedByProfileSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithNotAcceptableSize()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<AcceptableSizeSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithNoDiskUpgrade()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<UpgradeDiskSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithEpisodeAlreadyInQueue()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<NotInQueueSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithOverRetention()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<RetentionSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithAiredBeforeCustomStartDateCutoff()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<CustomStartDateSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WithLanguageNotWanted()
|
|
||||||
{
|
|
||||||
Mocker.GetMock<LanguageSpecification>()
|
|
||||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
|
||||||
.Returns(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_allowed_if_all_conditions_are_met()
|
public void should_call_all_specifications()
|
||||||
{
|
{
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.None);
|
throw new InvalidAsynchronousStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_profile_is_not_allowed()
|
|
||||||
{
|
|
||||||
WithProfileNotAllowed();
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.QualityNotWanted);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_size_is_not_allowed()
|
|
||||||
{
|
|
||||||
WithNotAcceptableSize();
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_disk_is_not_upgrade()
|
|
||||||
{
|
|
||||||
WithNoDiskUpgrade();
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.ExistingQualityIsEqualOrBetter);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_episode_is_already_in_queue()
|
|
||||||
{
|
|
||||||
WithEpisodeAlreadyInQueue();
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.AlreadyInQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_report_is_over_retention()
|
|
||||||
{
|
|
||||||
WithOverRetention();
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.Retention);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_episode_aired_before_cutoff()
|
|
||||||
{
|
|
||||||
WithAiredBeforeCustomStartDateCutoff();
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.AiredAfterCustomStartDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_none_of_conditions_are_met()
|
|
||||||
{
|
|
||||||
WithNoDiskUpgrade();
|
|
||||||
WithNotAcceptableSize();
|
|
||||||
WithProfileNotAllowed();
|
|
||||||
WithOverRetention();
|
|
||||||
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.QualityNotWanted);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_not_be_allowed_if_language_is_not_wanted()
|
|
||||||
{
|
|
||||||
WithLanguageNotWanted();
|
|
||||||
|
|
||||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.LanguageNotWanted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test
|
namespace NzbDrone.Core.Test
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
using Moq;
|
using Moq;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.Framework
|
namespace NzbDrone.Core.Test.Framework
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Core.Helpers;
|
using NzbDrone.Core.Helpers;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.HelperTests
|
namespace NzbDrone.Core.Test.HelperTests
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Core.Helpers;
|
using NzbDrone.Core.Helpers;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests
|
namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Test.Indexers;
|
using NzbDrone.Core.Test.Indexers;
|
||||||
using NzbDrone.Core.Test.ProviderTests;
|
using NzbDrone.Core.Test.ProviderTests;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Test.ProviderTests;
|
using NzbDrone.Core.Test.ProviderTests;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.JobTests
|
namespace NzbDrone.Core.Test.JobTests
|
||||||
|
@ -8,15 +8,10 @@
|
|||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Jobs.Implementations;
|
using NzbDrone.Core.Jobs.Implementations;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Jobs;
|
|
||||||
using NzbDrone.Core.Model;
|
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.JobTests
|
namespace NzbDrone.Core.Test.JobTests
|
||||||
{
|
{
|
||||||
@ -48,12 +43,6 @@ public void Setup()
|
|||||||
[Test]
|
[Test]
|
||||||
public void SeasonSearch_partial_season_success()
|
public void SeasonSearch_partial_season_success()
|
||||||
{
|
{
|
||||||
var resultItems = Builder<SearchHistoryItem>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SearchError = ReportRejectionReasons.None)
|
|
||||||
.With(e => e.Success = true)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
Mocker.GetMock<SearchProvider>()
|
Mocker.GetMock<SearchProvider>()
|
||||||
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
|
.Setup(c => c.PartialSeasonSearch(notification, 1, 1))
|
||||||
.Returns(_episodes.Select(e => e.EpisodeNumber).ToList());
|
.Returns(_episodes.Select(e => e.EpisodeNumber).ToList());
|
||||||
|
@ -276,39 +276,6 @@
|
|||||||
<RegexTestSelector>
|
<RegexTestSelector>
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.Datastore\.BasicRepositoryFixture\..*</RegularExpression>
|
<RegularExpression>NzbDrone\.Core\.Test\.Datastore\.BasicRepositoryFixture\..*</RegularExpression>
|
||||||
</RegexTestSelector>
|
</RegexTestSelector>
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.AcceptableSizeSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.AllowedDownloadSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.AllowedReleaseGroupSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.CustomStartDateSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.LanguageSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.MonitoredEpisodeSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.QualityAllowedByProfileSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.QualityUpgradeSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.RetentionSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradeDiskSpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradeHistorySpecificationFixture\..*</RegularExpression>
|
|
||||||
</RegexTestSelector>
|
|
||||||
<RegexTestSelector>
|
<RegexTestSelector>
|
||||||
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradePossibleSpecificationFixture\..*</RegularExpression>
|
<RegularExpression>NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradePossibleSpecificationFixture\..*</RegularExpression>
|
||||||
</RegexTestSelector>
|
</RegexTestSelector>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
using NzbDrone.Core.Download.Clients;
|
using NzbDrone.Core.Download.Clients;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
using NzbDrone.Core.ExternalNotification;
|
using NzbDrone.Core.ExternalNotification;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
using NzbDrone.Core.Model.Xbmc;
|
using NzbDrone.Core.Model.Xbmc;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Xbmc;
|
using NzbDrone.Core.Providers.Xbmc;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests
|
||||||
@ -23,8 +16,7 @@ public class CheckReportFixture : TestBase
|
|||||||
private Series _series;
|
private Series _series;
|
||||||
private Episode _episode;
|
private Episode _episode;
|
||||||
private EpisodeParseResult _episodeParseResult;
|
private EpisodeParseResult _episodeParseResult;
|
||||||
private SearchHistoryItem _searchHistoryItem;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
@ -44,8 +36,6 @@ public void Setup()
|
|||||||
.With(p => p.Episodes = new List<Episode> { _episode })
|
.With(p => p.Episodes = new List<Episode> { _episode })
|
||||||
.With(p => p.Series = _series)
|
.With(p => p.Series = _series)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_searchHistoryItem = new SearchHistoryItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -54,10 +44,7 @@ public void should_return_WrongEpisode_is_parseResult_doesnt_have_airdate()
|
|||||||
_episodeParseResult.AirDate = null;
|
_episodeParseResult.AirDate = null;
|
||||||
|
|
||||||
Mocker.Resolve<DailyEpisodeSearch>()
|
Mocker.Resolve<DailyEpisodeSearch>()
|
||||||
.CheckReport(_series, new {Episode = _episode}, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult).Should().BeFalse();
|
||||||
.SearchError
|
|
||||||
.Should()
|
|
||||||
.Be(ReportRejectionReasons.WrongEpisode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -66,20 +53,17 @@ public void should_return_WrongEpisode_is_parseResult_airdate_doesnt_match_episo
|
|||||||
_episodeParseResult.AirDate = _episode.AirDate.Value.AddDays(-10);
|
_episodeParseResult.AirDate = _episode.AirDate.Value.AddDays(-10);
|
||||||
|
|
||||||
Mocker.Resolve<DailyEpisodeSearch>()
|
Mocker.Resolve<DailyEpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
|
||||||
.Should()
|
.Should()
|
||||||
.Be(ReportRejectionReasons.WrongEpisode);
|
.BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_return_error_when_airDates_match()
|
public void should_not_return_error_when_airDates_match()
|
||||||
{
|
{
|
||||||
Mocker.Resolve<DailyEpisodeSearch>()
|
Mocker.Resolve<DailyEpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
.Should().BeFalse();
|
||||||
.Should()
|
|
||||||
.Be(ReportRejectionReasons.None);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests
|
||||||
|
@ -1,18 +1,10 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests
|
||||||
@ -23,7 +15,6 @@ public class CheckReportFixture : TestBase
|
|||||||
private Series _series;
|
private Series _series;
|
||||||
private Episode _episode;
|
private Episode _episode;
|
||||||
private EpisodeParseResult _episodeParseResult;
|
private EpisodeParseResult _episodeParseResult;
|
||||||
private SearchHistoryItem _searchHistoryItem;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
@ -46,7 +37,6 @@ public void Setup()
|
|||||||
.With(p => p.Series = _series)
|
.With(p => p.Series = _series)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_searchHistoryItem = new SearchHistoryItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -55,10 +45,9 @@ public void should_return_WrongSeason_when_season_doesnt_match()
|
|||||||
_episode.SeasonNumber = 10;
|
_episode.SeasonNumber = 10;
|
||||||
|
|
||||||
Mocker.Resolve<EpisodeSearch>()
|
Mocker.Resolve<EpisodeSearch>()
|
||||||
.CheckReport(_series, new {Episode = _episode}, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new {Episode = _episode}, _episodeParseResult)
|
||||||
.SearchError
|
|
||||||
.Should()
|
.Should()
|
||||||
.Be(ReportRejectionReasons.WrongSeason);
|
.BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -67,20 +56,18 @@ public void should_return_WrongEpisode_when_episode_doesnt_match()
|
|||||||
_episode.EpisodeNumber = 10;
|
_episode.EpisodeNumber = 10;
|
||||||
|
|
||||||
Mocker.Resolve<EpisodeSearch>()
|
Mocker.Resolve<EpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
|
||||||
.Should()
|
.Should()
|
||||||
.Be(ReportRejectionReasons.WrongEpisode);
|
.BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_return_error_when_season_and_episode_match()
|
public void should_not_return_error_when_season_and_episode_match()
|
||||||
{
|
{
|
||||||
Mocker.Resolve<EpisodeSearch>()
|
Mocker.Resolve<EpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
|
||||||
.Should()
|
.Should()
|
||||||
.Be(ReportRejectionReasons.None);
|
.BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -92,10 +79,9 @@ public void should_return_WrongSeason_when_season_doesnt_match_for_scene_series(
|
|||||||
_episode.EpisodeNumber = 10;
|
_episode.EpisodeNumber = 10;
|
||||||
|
|
||||||
Mocker.Resolve<EpisodeSearch>()
|
Mocker.Resolve<EpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
.Should()
|
||||||
.Should()
|
.BeFalse();
|
||||||
.Be(ReportRejectionReasons.WrongSeason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -107,10 +93,9 @@ public void should_return_WrongEpisode_when_episode_doesnt_match_for_scene_serie
|
|||||||
_episode.EpisodeNumber = 10;
|
_episode.EpisodeNumber = 10;
|
||||||
|
|
||||||
Mocker.Resolve<EpisodeSearch>()
|
Mocker.Resolve<EpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
.Should()
|
||||||
.Should()
|
.BeFalse();
|
||||||
.Be(ReportRejectionReasons.WrongEpisode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -123,10 +108,9 @@ public void should_not_return_error_when_season_and_episode_match_for_scene_seri
|
|||||||
_episode.EpisodeNumber = 10;
|
_episode.EpisodeNumber = 10;
|
||||||
|
|
||||||
Mocker.Resolve<EpisodeSearch>()
|
Mocker.Resolve<EpisodeSearch>()
|
||||||
.CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
|
||||||
.SearchError
|
|
||||||
.Should()
|
.Should()
|
||||||
.Be(ReportRejectionReasons.None);
|
.BeTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests
|
||||||
@ -23,8 +17,7 @@ public class CheckReportFixture : TestBase
|
|||||||
private Series _series;
|
private Series _series;
|
||||||
private List<Episode> _episodes;
|
private List<Episode> _episodes;
|
||||||
private EpisodeParseResult _episodeParseResult;
|
private EpisodeParseResult _episodeParseResult;
|
||||||
private SearchHistoryItem _searchHistoryItem;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
@ -45,23 +38,22 @@ public void Setup()
|
|||||||
.With(p => p.SeasonNumber = 1)
|
.With(p => p.SeasonNumber = 1)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_searchHistoryItem = new SearchHistoryItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_wrongSeason_when_season_does_not_match()
|
public void should_return_wrongSeason_when_season_does_not_match()
|
||||||
{
|
{
|
||||||
Mocker.Resolve<PartialSeasonSearch>()
|
Mocker.Resolve<PartialSeasonSearch>()
|
||||||
.CheckReport(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult)
|
||||||
.SearchError.Should().Be(ReportRejectionReasons.WrongSeason);
|
.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_return_error_when_season_matches()
|
public void should_not_return_error_when_season_matches()
|
||||||
{
|
{
|
||||||
Mocker.Resolve<PartialSeasonSearch>()
|
Mocker.Resolve<PartialSeasonSearch>()
|
||||||
.CheckReport(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult, _searchHistoryItem)
|
.IsEpisodeMatch(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult)
|
||||||
.SearchError.Should().Be(ReportRejectionReasons.None);
|
.Should().BeFalse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||||
|
@ -1,38 +1,33 @@
|
|||||||
using System;
|
/*
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Providers.Search;
|
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
using NzbDrone.Core.Repository.Search;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ProcessResultsFixture : TestBase
|
public class ProcessResultsFixture : CoreTest<TestSearch>
|
||||||
{
|
{
|
||||||
private Series _matchingSeries;
|
private Series _matchingSeries;
|
||||||
private Series _mismatchedSeries;
|
private Series _mismatchedSeries;
|
||||||
private Series _nullSeries = null;
|
private Series _nullSeries = null;
|
||||||
|
|
||||||
private SearchHistory _searchHistory;
|
private EpisodeSearchResult _episodeSearchResult;
|
||||||
private ProgressNotification _notification;
|
private ProgressNotification _notification;
|
||||||
|
|
||||||
private List<Episode> _episodes;
|
private List<Episode> _episodes;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
@ -46,7 +41,7 @@ public void Setup()
|
|||||||
.With(s => s.Title = "Not 30 Rock")
|
.With(s => s.Title = "Not 30 Rock")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_searchHistory = new SearchHistory();
|
_episodeSearchResult = new EpisodeSearchResult();
|
||||||
_notification = new ProgressNotification("Test");
|
_notification = new ProgressNotification("Test");
|
||||||
|
|
||||||
_episodes = Builder<Episode>
|
_episodes = Builder<Episode>
|
||||||
@ -90,132 +85,26 @@ private void WithFailingDownload()
|
|||||||
.Returns(false);
|
.Returns(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithQualityNeeded()
|
private void WithApprovedDecisions()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>()
|
Mocker.GetMock<IDownloadDirector>()
|
||||||
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
.Setup(s => s.GetDownloadDecision(It.IsAny<EpisodeParseResult>()))
|
||||||
.Returns(ReportRejectionReasons.None);
|
.Returns(new DownloadDecision(new string[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WithQualityNotNeeded()
|
private void WithDeclinedDecisions()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>()
|
Mocker.GetMock<IDownloadDirector>()
|
||||||
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
.Setup(s => s.GetDownloadDecision(It.IsAny<EpisodeParseResult>()))
|
||||||
.Returns(ReportRejectionReasons.ExistingQualityIsEqualOrBetter);
|
.Returns(new DownloadDecision(new[] { "Rejection reason" }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
Times.Once());
|
||||||
public void should_process_higher_quality_results_first()
|
|
||||||
{
|
|
||||||
WithMatchingSeries();
|
|
||||||
WithSuccessfulDownload();
|
|
||||||
|
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
||||||
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
|
|
||||||
.With(c => c.Age = 10)
|
|
||||||
.Random(1)
|
|
||||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true))
|
|
||||||
.With(c => c.Age = 100)
|
|
||||||
.Build()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
|
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>()
|
|
||||||
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.Bluray1080p)))
|
|
||||||
.Returns(ReportRejectionReasons.None);
|
|
||||||
|
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
|
||||||
|
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
||||||
result.SearchHistoryItems.Should().Contain(s => s.Success);
|
|
||||||
|
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Once());
|
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Once());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_process_newer_reports_first()
|
|
||||||
{
|
|
||||||
WithMatchingSeries();
|
|
||||||
WithSuccessfulDownload();
|
|
||||||
|
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
||||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true))
|
|
||||||
.With(c => c.Age = 300)
|
|
||||||
.Build()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
parseResults[2].Age = 100;
|
|
||||||
|
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>()
|
|
||||||
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(ReportRejectionReasons.None);
|
|
||||||
|
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
|
||||||
|
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
||||||
result.SearchHistoryItems.Should().Contain(s => s.Success);
|
|
||||||
|
|
||||||
|
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Age != 100)), Times.Never());
|
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Age == 100)), Times.Once());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_check_other_reports_when_quality_is_not_wanted()
|
|
||||||
{
|
|
||||||
WithMatchingSeries();
|
|
||||||
WithQualityNotNeeded();
|
|
||||||
|
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
||||||
.With(c => c.Quality = new QualityModel(Quality.DVD, true))
|
|
||||||
.Build()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
|
||||||
|
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
||||||
result.SearchHistoryItems.Should().NotContain(s => s.Success);
|
|
||||||
|
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Exactly(5));
|
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Never());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_should_skip_if_series_is_not_watched()
|
|
||||||
{
|
|
||||||
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
||||||
.All()
|
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
||||||
.With(e => e.Quality = new QualityModel(Quality.HDTV720p, false))
|
|
||||||
.Build()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
WithNullSeries();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
|
||||||
result.SearchHistoryItems.Should().NotContain(s => s.Success);
|
|
||||||
|
|
||||||
Mocker.GetMock<DownloadProvider>().Verify(c => c.DownloadReport(It.IsAny<EpisodeParseResult>()),
|
|
||||||
Times.Never());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_skip_if_series_does_not_match_searched_series()
|
public void should_skip_if_series_does_not_match_searched_series()
|
||||||
@ -231,7 +120,7 @@ public void should_skip_if_series_does_not_match_searched_series()
|
|||||||
WithMisMatchedSeries();
|
WithMisMatchedSeries();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
||||||
@ -259,7 +148,7 @@ public void should_skip_if_episode_was_already_downloaded()
|
|||||||
WithSuccessfulDownload();
|
WithSuccessfulDownload();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
||||||
@ -294,7 +183,7 @@ public void should_try_next_report_if_download_fails()
|
|||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
result.SearchHistoryItems.Should().HaveCount(parseResults.Count);
|
||||||
@ -322,21 +211,22 @@ public void should_return_valid_successes_when_one_or_more_downloaded()
|
|||||||
WithMatchingSeries();
|
WithMatchingSeries();
|
||||||
WithSuccessfulDownload();
|
WithSuccessfulDownload();
|
||||||
|
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>()
|
Mocker.GetMock<DownloadDirector>()
|
||||||
.Setup(s => s.IsSatisfiedBy(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.Bluray1080p)))
|
.Setup(s => s.IsDownloadPermitted(It.Is<EpisodeParseResult>(d => d.Quality.Quality == Quality.Bluray1080p)))
|
||||||
.Returns(ReportRejectionReasons.None);
|
.Returns(ReportRejectionReasons.None);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = Mocker.Resolve<TestSearch>().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification);
|
var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
result.Successes.Should().NotBeNull();
|
result.Successes.Should().NotBeNull();
|
||||||
result.Successes.Should().NotBeEmpty();
|
result.Successes.Should().NotBeEmpty();
|
||||||
|
|
||||||
Mocker.GetMock<AllowedDownloadSpecification>().Verify(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()),
|
Mocker.GetMock<DownloadDirector>().Verify(c => c.IsDownloadPermitted(It.IsAny<EpisodeParseResult>()),
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.ReferenceData;
|
using NzbDrone.Core.ReferenceData;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Providers.Search;
|
using NzbDrone.Core.Providers.Search;
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||||
{
|
{
|
||||||
@ -21,11 +16,11 @@ public class TestSearch : SearchBase
|
|||||||
{
|
{
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
||||||
IIndexerService indexerService, SceneMappingService sceneMappingService,
|
IIndexerService indexerService, SceneMappingService sceneMappingService,
|
||||||
AllowedDownloadSpecification allowedDownloadSpecification, ISeriesRepository seriesRepository)
|
DownloadDirector downloadDirector, ISeriesRepository seriesRepository)
|
||||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||||
allowedDownloadSpecification)
|
downloadDirector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +54,10 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
return reports;
|
return reports;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, Repository.Search.SearchHistoryItem item)
|
public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult)
|
||||||
{
|
{
|
||||||
return item;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void FinalizeSearch(Series series, dynamic options, bool reportsFound, Model.Notification.ProgressNotification notification)
|
|
||||||
{
|
|
||||||
logger.Warn("Unable to find {0} in any of indexers.", series.Title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model.TvRage;
|
using NzbDrone.Core.Model.TvRage;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests
|
namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model.TvRage;
|
using NzbDrone.Core.Model.TvRage;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests
|
namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using NzbDrone.Core.Model.Xbmc;
|
using NzbDrone.Core.Model.Xbmc;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Xbmc;
|
using NzbDrone.Core.Providers.Xbmc;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common.AutoMoq;
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
using NLog;
|
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Model;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.DecisionEngine
|
|
||||||
{
|
|
||||||
public class AllowedDownloadSpecification
|
|
||||||
{
|
|
||||||
private readonly QualityAllowedByProfileSpecification _qualityAllowedByProfileSpecification;
|
|
||||||
private readonly UpgradeDiskSpecification _upgradeDiskSpecification;
|
|
||||||
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
|
|
||||||
private readonly NotInQueueSpecification _notInQueueSpecification;
|
|
||||||
private readonly RetentionSpecification _retentionSpecification;
|
|
||||||
private readonly AllowedReleaseGroupSpecification _allowedReleaseGroupSpecification;
|
|
||||||
private readonly CustomStartDateSpecification _customStartDateSpecification;
|
|
||||||
private readonly LanguageSpecification _languageSpecification;
|
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
||||||
|
|
||||||
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
|
||||||
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
|
||||||
NotInQueueSpecification notInQueueSpecification, RetentionSpecification retentionSpecification,
|
|
||||||
AllowedReleaseGroupSpecification allowedReleaseGroupSpecification, CustomStartDateSpecification customStartDateSpecification,
|
|
||||||
LanguageSpecification languageSpecification)
|
|
||||||
{
|
|
||||||
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
|
||||||
_upgradeDiskSpecification = upgradeDiskSpecification;
|
|
||||||
_acceptableSizeSpecification = acceptableSizeSpecification;
|
|
||||||
_notInQueueSpecification = notInQueueSpecification;
|
|
||||||
_retentionSpecification = retentionSpecification;
|
|
||||||
_allowedReleaseGroupSpecification = allowedReleaseGroupSpecification;
|
|
||||||
_customStartDateSpecification = customStartDateSpecification;
|
|
||||||
_languageSpecification = languageSpecification;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AllowedDownloadSpecification()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual ReportRejectionReasons IsSatisfiedBy(EpisodeParseResult subject)
|
|
||||||
{
|
|
||||||
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.QualityNotWanted;
|
|
||||||
if (!_customStartDateSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.AiredAfterCustomStartDate;
|
|
||||||
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.ExistingQualityIsEqualOrBetter;
|
|
||||||
if (!_languageSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.LanguageNotWanted;
|
|
||||||
if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.Retention;
|
|
||||||
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.Size;
|
|
||||||
if (!_allowedReleaseGroupSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.ReleaseGroupNotWanted;
|
|
||||||
if (!_notInQueueSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.AlreadyInQueue;
|
|
||||||
|
|
||||||
logger.Debug("Episode {0} is needed", subject);
|
|
||||||
return ReportRejectionReasons.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
22
NzbDrone.Core/DecisionEngine/DownloadDecision.cs
Normal file
22
NzbDrone.Core/DecisionEngine/DownloadDecision.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.DecisionEngine
|
||||||
|
{
|
||||||
|
public class DownloadDecision
|
||||||
|
{
|
||||||
|
public IEnumerable<string> Rejections { get; private set; }
|
||||||
|
public bool Approved
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return !Rejections.Any();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadDecision(params string[] rejections)
|
||||||
|
{
|
||||||
|
Rejections = rejections.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
NzbDrone.Core/DecisionEngine/DownloadDirector.cs
Normal file
32
NzbDrone.Core/DecisionEngine/DownloadDirector.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Model;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.DecisionEngine
|
||||||
|
{
|
||||||
|
public interface IDownloadDirector
|
||||||
|
{
|
||||||
|
DownloadDecision GetDownloadDecision(EpisodeParseResult episodeParseResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DownloadDirector : IDownloadDirector
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<IFetchableSpecification> _specifications;
|
||||||
|
|
||||||
|
public DownloadDirector(IEnumerable<IFetchableSpecification> specifications)
|
||||||
|
{
|
||||||
|
_specifications = specifications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadDecision GetDownloadDecision(EpisodeParseResult episodeParseResult)
|
||||||
|
{
|
||||||
|
var rejections = _specifications
|
||||||
|
.Where(spec => !spec.IsSatisfiedBy(episodeParseResult))
|
||||||
|
.Select(spec => spec.RejectionReason).ToArray();
|
||||||
|
|
||||||
|
episodeParseResult.Decision = new DownloadDecision(rejections);
|
||||||
|
|
||||||
|
return episodeParseResult.Decision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
namespace NzbDrone.Core.DecisionEngine
|
|
||||||
{
|
|
||||||
public enum ReportRejectionReasons
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
WrongSeries = 1,
|
|
||||||
QualityNotWanted = 2,
|
|
||||||
WrongSeason = 3,
|
|
||||||
WrongEpisode = 4,
|
|
||||||
Size = 5,
|
|
||||||
Retention = 6,
|
|
||||||
ExistingQualityIsEqualOrBetter = 7,
|
|
||||||
Cutoff = 8,
|
|
||||||
AlreadyInQueue = 9,
|
|
||||||
DownloadClientFailure = 10,
|
|
||||||
Skipped = 11,
|
|
||||||
Failure = 12,
|
|
||||||
ReleaseGroupNotWanted = 13,
|
|
||||||
AiredAfterCustomStartDate = 14,
|
|
||||||
LanguageNotWanted = 15
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -17,23 +15,17 @@ public class RssSyncJob : IJob
|
|||||||
{
|
{
|
||||||
private readonly DownloadProvider _downloadProvider;
|
private readonly DownloadProvider _downloadProvider;
|
||||||
private readonly IIndexerService _indexerService;
|
private readonly IIndexerService _indexerService;
|
||||||
private readonly MonitoredEpisodeSpecification _isMonitoredEpisodeSpecification;
|
private readonly IDownloadDirector DownloadDirector;
|
||||||
private readonly AllowedDownloadSpecification _allowedDownloadSpecification;
|
|
||||||
private readonly UpgradeHistorySpecification _upgradeHistorySpecification;
|
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
|
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public RssSyncJob(DownloadProvider downloadProvider, IIndexerService indexerService,
|
public RssSyncJob(DownloadProvider downloadProvider, IIndexerService indexerService, IDownloadDirector downloadDirector, IConfigService configService)
|
||||||
MonitoredEpisodeSpecification isMonitoredEpisodeSpecification, AllowedDownloadSpecification allowedDownloadSpecification,
|
|
||||||
UpgradeHistorySpecification upgradeHistorySpecification, IConfigService configService)
|
|
||||||
{
|
{
|
||||||
_downloadProvider = downloadProvider;
|
_downloadProvider = downloadProvider;
|
||||||
_indexerService = indexerService;
|
_indexerService = indexerService;
|
||||||
_isMonitoredEpisodeSpecification = isMonitoredEpisodeSpecification;
|
DownloadDirector = downloadDirector;
|
||||||
_allowedDownloadSpecification = allowedDownloadSpecification;
|
|
||||||
_upgradeHistorySpecification = upgradeHistorySpecification;
|
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +69,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_isMonitoredEpisodeSpecification.IsSatisfiedBy(episodeParseResult) &&
|
if (DownloadDirector.GetDownloadDecision(episodeParseResult).Approved)
|
||||||
_allowedDownloadSpecification.IsSatisfiedBy(episodeParseResult) == ReportRejectionReasons.None &&
|
|
||||||
_upgradeHistorySpecification.IsSatisfiedBy(episodeParseResult))
|
|
||||||
{
|
{
|
||||||
_downloadProvider.DownloadReport(episodeParseResult);
|
_downloadProvider.DownloadReport(episodeParseResult);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Providers;
|
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Model
|
namespace NzbDrone.Core.Model
|
||||||
{
|
{
|
||||||
@ -21,6 +19,8 @@ public string CleanTitle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DownloadDecision Decision { get; set; }
|
||||||
|
|
||||||
public string EpisodeTitle { get; set; }
|
public string EpisodeTitle { get; set; }
|
||||||
|
|
||||||
public int SeasonNumber { get; set; }
|
public int SeasonNumber { get; set; }
|
||||||
|
@ -188,9 +188,10 @@
|
|||||||
<Compile Include="Datastore\BasicRepository.cs" />
|
<Compile Include="Datastore\BasicRepository.cs" />
|
||||||
<Compile Include="Datastore\ObjectDbFactory.cs" />
|
<Compile Include="Datastore\ObjectDbFactory.cs" />
|
||||||
<Compile Include="Datastore\SiaqodbProxy.cs" />
|
<Compile Include="Datastore\SiaqodbProxy.cs" />
|
||||||
|
<Compile Include="DecisionEngine\DownloadDecision.cs" />
|
||||||
<Compile Include="DecisionEngine\IFetchableSpecification.cs" />
|
<Compile Include="DecisionEngine\IFetchableSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\AcceptableSizeSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\AllowedDownloadSpecification.cs" />
|
<Compile Include="DecisionEngine\DownloadDirector.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\AllowedReleaseGroupSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\AllowedReleaseGroupSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\NotInQueueSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\NotInQueueSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\CustomStartDateSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\CustomStartDateSpecification.cs" />
|
||||||
@ -336,9 +337,6 @@
|
|||||||
<Compile Include="Providers\XemCommunicationProvider.cs" />
|
<Compile Include="Providers\XemCommunicationProvider.cs" />
|
||||||
<Compile Include="Providers\XemProvider.cs" />
|
<Compile Include="Providers\XemProvider.cs" />
|
||||||
<Compile Include="Qualities\Quality.cs" />
|
<Compile Include="Qualities\Quality.cs" />
|
||||||
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
|
|
||||||
<Compile Include="Repository\Search\SearchHistory.cs" />
|
|
||||||
<Compile Include="DecisionEngine\ReportRejectionReasons.cs" />
|
|
||||||
<Compile Include="Tv\Season.cs" />
|
<Compile Include="Tv\Season.cs" />
|
||||||
<Compile Include="Providers\AutoConfigureProvider.cs">
|
<Compile Include="Providers\AutoConfigureProvider.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Converting
|
namespace NzbDrone.Core.Providers.Converting
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Converting
|
namespace NzbDrone.Core.Providers.Converting
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers
|
namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.ReferenceData;
|
using NzbDrone.Core.ReferenceData;
|
||||||
@ -12,8 +9,6 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Search
|
namespace NzbDrone.Core.Providers.Search
|
||||||
{
|
{
|
||||||
@ -22,10 +17,10 @@ public class DailyEpisodeSearch : SearchBase
|
|||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public DailyEpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
public DailyEpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
||||||
SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification,
|
SceneMappingService sceneMappingService, DownloadDirector downloadDirector,
|
||||||
ISeriesRepository seriesRepository)
|
ISeriesRepository seriesRepository)
|
||||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||||
allowedDownloadSpecification)
|
downloadDirector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,28 +55,18 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
return reports;
|
return reports;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult,
|
public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult)
|
||||||
SearchHistoryItem item)
|
|
||||||
{
|
{
|
||||||
Episode episode = options.Episode;
|
Episode episode = options.Episode;
|
||||||
|
|
||||||
if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value != episode.AirDate.Value)
|
if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value != episode.AirDate.Value)
|
||||||
{
|
{
|
||||||
logger.Trace("Episode AirDate does not match searched episode number, skipping.");
|
logger.Trace("Episode AirDate does not match searched episode number, skipping.");
|
||||||
item.SearchError = ReportRejectionReasons.WrongEpisode;
|
return false;
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification)
|
|
||||||
{
|
|
||||||
logger.Warn("Unable to find {0} in any of indexers.", options.Episode);
|
|
||||||
|
|
||||||
notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode.AirDate)
|
|
||||||
: String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.ReferenceData;
|
using NzbDrone.Core.ReferenceData;
|
||||||
@ -12,8 +9,6 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Search
|
namespace NzbDrone.Core.Providers.Search
|
||||||
{
|
{
|
||||||
@ -22,11 +17,11 @@ public class EpisodeSearch : SearchBase
|
|||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public EpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
public EpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
||||||
SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification,
|
SceneMappingService sceneMappingService, DownloadDirector downloadDirector,
|
||||||
ISeriesRepository seriesRepository)
|
ISeriesRepository seriesRepository)
|
||||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||||
allowedDownloadSpecification)
|
downloadDirector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EpisodeSearch()
|
public EpisodeSearch()
|
||||||
@ -51,7 +46,7 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
|
|
||||||
if (series.UseSceneNumbering)
|
if (series.UseSceneNumbering)
|
||||||
{
|
{
|
||||||
if(options.Episode.SceneSeasonNumber > 0 && options.Episode.SceneEpisodeNumber > 0)
|
if (options.Episode.SceneSeasonNumber > 0 && options.Episode.SceneEpisodeNumber > 0)
|
||||||
{
|
{
|
||||||
logger.Trace("Using Scene Numbering for: {0}", options.Episode);
|
logger.Trace("Using Scene Numbering for: {0}", options.Episode);
|
||||||
seasonNumber = options.Episode.SceneSeasonNumber;
|
seasonNumber = options.Episode.SceneSeasonNumber;
|
||||||
@ -76,55 +71,39 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
return reports;
|
return reports;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult,
|
public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult)
|
||||||
SearchHistoryItem item)
|
|
||||||
{
|
{
|
||||||
if(series.UseSceneNumbering && options.Episode.SeasonNumber > 0 && options.Episode.EpisodeNumber > 0)
|
if (series.UseSceneNumbering && options.Episode.SeasonNumber > 0 && options.Episode.EpisodeNumber > 0)
|
||||||
{
|
{
|
||||||
if (options.Episode.SceneSeasonNumber != episodeParseResult.SeasonNumber)
|
if (options.Episode.SceneSeasonNumber != episodeParseResult.SeasonNumber)
|
||||||
{
|
{
|
||||||
logger.Trace("Season number does not match searched season number, skipping.");
|
logger.Trace("Season number does not match searched season number, skipping.");
|
||||||
item.SearchError = ReportRejectionReasons.WrongSeason;
|
return false;
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!episodeParseResult.EpisodeNumbers.Contains(options.Episode.SceneEpisodeNumber))
|
if (!episodeParseResult.EpisodeNumbers.Contains(options.Episode.SceneEpisodeNumber))
|
||||||
{
|
{
|
||||||
logger.Trace("Episode number does not match searched episode number, skipping.");
|
logger.Trace("Episode number does not match searched episode number, skipping.");
|
||||||
item.SearchError = ReportRejectionReasons.WrongEpisode;
|
return false;
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.Episode.SeasonNumber != episodeParseResult.SeasonNumber)
|
if (options.Episode.SeasonNumber != episodeParseResult.SeasonNumber)
|
||||||
{
|
{
|
||||||
logger.Trace("Season number does not match searched season number, skipping.");
|
logger.Trace("Season number does not match searched season number, skipping.");
|
||||||
item.SearchError = ReportRejectionReasons.WrongSeason;
|
return false;
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!episodeParseResult.EpisodeNumbers.Contains(options.Episode.EpisodeNumber))
|
if (!episodeParseResult.EpisodeNumbers.Contains(options.Episode.EpisodeNumber))
|
||||||
{
|
{
|
||||||
logger.Trace("Episode number does not match searched episode number, skipping.");
|
logger.Trace("Episode number does not match searched episode number, skipping.");
|
||||||
item.SearchError = ReportRejectionReasons.WrongEpisode;
|
return false;
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification)
|
|
||||||
{
|
|
||||||
logger.Warn("Unable to find {0} in any of indexers.", options.Episode);
|
|
||||||
|
|
||||||
notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode)
|
|
||||||
: String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Search
|
namespace NzbDrone.Core.Providers.Search
|
||||||
{
|
{
|
||||||
@ -22,11 +20,11 @@ public class PartialSeasonSearch : SearchBase
|
|||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public PartialSeasonSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
public PartialSeasonSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
||||||
SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification,
|
SceneMappingService sceneMappingService, DownloadDirector downloadDirector,
|
||||||
ISeriesRepository seriesRepository)
|
ISeriesRepository seriesRepository)
|
||||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||||
allowedDownloadSpecification)
|
downloadDirector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public PartialSeasonSearch()
|
public PartialSeasonSearch()
|
||||||
@ -54,7 +52,7 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
var title = GetSearchTitle(series);
|
var title = GetSearchTitle(series);
|
||||||
var prefixes = GetEpisodeNumberPrefixes(episodes.Select(e => e.EpisodeNumber));
|
var prefixes = GetEpisodeNumberPrefixes(episodes.Select(e => e.EpisodeNumber));
|
||||||
|
|
||||||
foreach(var p in prefixes)
|
foreach (var p in prefixes)
|
||||||
{
|
{
|
||||||
var prefix = p;
|
var prefix = p;
|
||||||
|
|
||||||
@ -62,13 +60,13 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock(reportsLock)
|
lock (reportsLock)
|
||||||
{
|
{
|
||||||
reports.AddRange(indexer.FetchPartialSeason(title, options.SeasonNumber, prefix));
|
reports.AddRange(indexer.FetchPartialSeason(title, options.SeasonNumber, prefix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.ErrorException(
|
logger.ErrorException(
|
||||||
String.Format(
|
String.Format(
|
||||||
@ -82,27 +80,17 @@ public override List<EpisodeParseResult> PerformSearch(Series series, dynamic op
|
|||||||
return reports;
|
return reports;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult,
|
public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult)
|
||||||
SearchHistoryItem item)
|
|
||||||
{
|
{
|
||||||
if(options.SeasonNumber != episodeParseResult.SeasonNumber)
|
if (options.SeasonNumber != episodeParseResult.SeasonNumber)
|
||||||
{
|
{
|
||||||
logger.Trace("Season number does not match searched season number, skipping.");
|
logger.Trace("Season number does not match searched season number, skipping.");
|
||||||
item.SearchError = ReportRejectionReasons.WrongSeason;
|
return false;
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification)
|
|
||||||
{
|
|
||||||
logger.Warn("Unable to find {0} - Season {1} in any of indexers.", series.Title, options.SeasonNumber);
|
|
||||||
|
|
||||||
notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0} Season {1:00}, that matches your preferences.", series.Title, options.SeasonNumber)
|
|
||||||
: String.Format("Sorry, couldn't find {0} Season {1:00} in any of indexers.", series.Title, options.SeasonNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<int> GetEpisodeNumberPrefixes(IEnumerable<int> episodeNumbers)
|
private List<int> GetEpisodeNumberPrefixes(IEnumerable<int> episodeNumbers)
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Datastore;
|
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.ReferenceData;
|
using NzbDrone.Core.ReferenceData;
|
||||||
@ -12,7 +10,6 @@
|
|||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Repository.Search;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Search
|
namespace NzbDrone.Core.Providers.Search
|
||||||
{
|
{
|
||||||
@ -23,20 +20,20 @@ public abstract class SearchBase
|
|||||||
protected readonly DownloadProvider _downloadProvider;
|
protected readonly DownloadProvider _downloadProvider;
|
||||||
protected readonly IIndexerService _indexerService;
|
protected readonly IIndexerService _indexerService;
|
||||||
protected readonly SceneMappingService _sceneMappingService;
|
protected readonly SceneMappingService _sceneMappingService;
|
||||||
protected readonly AllowedDownloadSpecification _allowedDownloadSpecification;
|
protected readonly DownloadDirector DownloadDirector;
|
||||||
|
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
protected SearchBase(ISeriesRepository seriesRepository, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
protected SearchBase(ISeriesRepository seriesRepository, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
||||||
IIndexerService indexerService, SceneMappingService sceneMappingService,
|
IIndexerService indexerService, SceneMappingService sceneMappingService,
|
||||||
AllowedDownloadSpecification allowedDownloadSpecification)
|
DownloadDirector downloadDirector)
|
||||||
{
|
{
|
||||||
_seriesRepository = seriesRepository;
|
_seriesRepository = seriesRepository;
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_downloadProvider = downloadProvider;
|
_downloadProvider = downloadProvider;
|
||||||
_indexerService = indexerService;
|
_indexerService = indexerService;
|
||||||
_sceneMappingService = sceneMappingService;
|
_sceneMappingService = sceneMappingService;
|
||||||
_allowedDownloadSpecification = allowedDownloadSpecification;
|
DownloadDirector = downloadDirector;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SearchBase()
|
protected SearchBase()
|
||||||
@ -44,123 +41,88 @@ protected SearchBase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<EpisodeParseResult> PerformSearch(Series series, dynamic options, ProgressNotification notification);
|
public abstract List<EpisodeParseResult> PerformSearch(Series series, dynamic options, ProgressNotification notification);
|
||||||
public abstract SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult,
|
public abstract bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult);
|
||||||
SearchHistoryItem item);
|
|
||||||
|
|
||||||
protected abstract void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification);
|
|
||||||
|
|
||||||
public virtual List<Int32> Search(Series series, dynamic options, ProgressNotification notification)
|
public virtual List<Int32> Search(Series series, dynamic options, ProgressNotification notification)
|
||||||
{
|
{
|
||||||
if (options == null)
|
if (options == null)
|
||||||
throw new ArgumentNullException(options);
|
throw new ArgumentNullException(options);
|
||||||
|
|
||||||
var searchResult = new SearchHistory
|
|
||||||
{
|
|
||||||
SearchTime = DateTime.Now,
|
|
||||||
SeriesId = series.Id,
|
|
||||||
EpisodeId = options.GetType().GetProperty("Episode") != null ? options.Episode.EpisodeId : null,
|
|
||||||
SeasonNumber = options.GetType().GetProperty("SeasonNumber") != null ? options.SeasonNumber : null
|
|
||||||
};
|
|
||||||
|
|
||||||
List<EpisodeParseResult> reports = PerformSearch(series, options, notification);
|
List<EpisodeParseResult> reports = PerformSearch(series, options, notification);
|
||||||
|
|
||||||
logger.Debug("Finished searching all indexers. Total {0}", reports.Count);
|
logger.Debug("Finished searching all indexers. Total {0}", reports.Count);
|
||||||
notification.CurrentMessage = "Processing search results";
|
notification.CurrentMessage = "Processing search results";
|
||||||
|
|
||||||
ProcessReports(series, options, reports, searchResult, notification);
|
|
||||||
|
|
||||||
if(searchResult.Successes.Any())
|
var result = ProcessReports(series, options, reports);
|
||||||
return searchResult.Successes;
|
|
||||||
|
|
||||||
FinalizeSearch(series, options, reports.Any(), notification);
|
if (!result.Grabbed.Any())
|
||||||
return new List<Int32>();
|
{
|
||||||
|
logger.Warn("Unable to find {0} in any of indexers.", options.Episode);
|
||||||
|
|
||||||
|
notification.CurrentMessage = reports.Any() ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode)
|
||||||
|
: String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.Grabbed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual SearchHistory ProcessReports(Series series, dynamic options, List<EpisodeParseResult> episodeParseResults,
|
public void ProcessReports(Series series, dynamic options, List<EpisodeParseResult> episodeParseResults)
|
||||||
SearchHistory searchResult, ProgressNotification notification)
|
|
||||||
{
|
{
|
||||||
var items = new List<SearchHistoryItem>();
|
|
||||||
searchResult.Successes = new List<Int32>();
|
|
||||||
|
|
||||||
foreach(var episodeParseResult in episodeParseResults
|
var sortedResults = episodeParseResults.OrderByDescending(c => c.Quality)
|
||||||
.OrderByDescending(c => c.Quality)
|
.ThenBy(c => c.EpisodeNumbers.MinOrDefault())
|
||||||
.ThenBy(c => c.EpisodeNumbers.MinOrDefault())
|
.ThenBy(c => c.Age);
|
||||||
.ThenBy(c => c.Age))
|
|
||||||
|
foreach (var episodeParseResult in sortedResults)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = new SearchHistoryItem
|
|
||||||
{
|
|
||||||
ReportTitle = episodeParseResult.OriginalString,
|
|
||||||
NzbUrl = episodeParseResult.NzbUrl,
|
|
||||||
Indexer = episodeParseResult.Indexer,
|
|
||||||
Quality = episodeParseResult.Quality.Quality,
|
|
||||||
Proper = episodeParseResult.Quality.Proper,
|
|
||||||
Size = episodeParseResult.Size,
|
|
||||||
Age = episodeParseResult.Age,
|
|
||||||
Language = episodeParseResult.Language
|
|
||||||
};
|
|
||||||
|
|
||||||
items.Add(item);
|
logger.Trace("Analyzing report " + episodeParseResult);
|
||||||
|
|
||||||
logger.Trace("Analysing report " + episodeParseResult);
|
|
||||||
episodeParseResult.Series = _seriesRepository.GetByTitle(episodeParseResult.CleanTitle);
|
episodeParseResult.Series = _seriesRepository.GetByTitle(episodeParseResult.CleanTitle);
|
||||||
|
|
||||||
if(episodeParseResult.Series == null || ((ModelBase)episodeParseResult.Series).Id != series.Id)
|
if (episodeParseResult.Series == null || episodeParseResult.Series.Id != series.Id)
|
||||||
{
|
{
|
||||||
item.SearchError = ReportRejectionReasons.WrongSeries;
|
episodeParseResult.Decision = new DownloadDecision("Invalid Series");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
episodeParseResult.Episodes = _episodeService.GetEpisodesByParseResult(episodeParseResult);
|
episodeParseResult.Episodes = _episodeService.GetEpisodesByParseResult(episodeParseResult);
|
||||||
|
|
||||||
if (searchResult.Successes.Intersect(episodeParseResult.Episodes.Select(e => e.Id)).Any())
|
|
||||||
|
if (!IsEpisodeMatch(series, options, episodeParseResult))
|
||||||
{
|
{
|
||||||
item.SearchError = ReportRejectionReasons.Skipped;
|
episodeParseResult.Decision = new DownloadDecision("Incorrect Episode/Season");
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckReport(series, options, episodeParseResult, item);
|
var downloadDecision = DownloadDirector.GetDownloadDecision(episodeParseResult);
|
||||||
if (item.SearchError != ReportRejectionReasons.None)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
item.SearchError = _allowedDownloadSpecification.IsSatisfiedBy(episodeParseResult);
|
if (downloadDecision.Approved)
|
||||||
|
|
||||||
if(item.SearchError == ReportRejectionReasons.None)
|
|
||||||
{
|
{
|
||||||
if(DownloadReport(notification, episodeParseResult, item))
|
DownloadReport(episodeParseResult);
|
||||||
searchResult.Successes.AddRange(episodeParseResult.Episodes.Select(e => e.Id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.ErrorException("An error has occurred while processing parse result items from " + episodeParseResult, e);
|
logger.ErrorException("An error has occurred while processing parse result items from " + episodeParseResult, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResult.SearchHistoryItems = items;
|
|
||||||
return searchResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Boolean DownloadReport(ProgressNotification notification, EpisodeParseResult episodeParseResult, SearchHistoryItem item)
|
public virtual Boolean DownloadReport(EpisodeParseResult episodeParseResult)
|
||||||
{
|
{
|
||||||
logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_downloadProvider.DownloadReport(episodeParseResult))
|
if (_downloadProvider.DownloadReport(episodeParseResult))
|
||||||
{
|
{
|
||||||
notification.CurrentMessage = String.Format("{0} Added to download queue", episodeParseResult);
|
|
||||||
item.Success = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.SearchError = ReportRejectionReasons.DownloadClientFailure;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.ErrorException("Unable to add report to download queue." + episodeParseResult, e);
|
logger.ErrorException("Unable to add report to download queue." + episodeParseResult, e);
|
||||||
notification.CurrentMessage = String.Format("Unable to add report to download queue. {0}", episodeParseResult);
|
|
||||||
item.SearchError = ReportRejectionReasons.DownloadClientFailure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -170,7 +132,7 @@ public virtual string GetSearchTitle(Series series, int seasonNumber = -1)
|
|||||||
{
|
{
|
||||||
var seasonTitle = _sceneMappingService.GetSceneName(series.Id, seasonNumber);
|
var seasonTitle = _sceneMappingService.GetSceneName(series.Id, seasonNumber);
|
||||||
|
|
||||||
if(!String.IsNullOrWhiteSpace(seasonTitle))
|
if (!String.IsNullOrWhiteSpace(seasonTitle))
|
||||||
return seasonTitle;
|
return seasonTitle;
|
||||||
|
|
||||||
var title = _sceneMappingService.GetSceneName(series.Id);
|
var title = _sceneMappingService.GetSceneName(series.Id);
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
using NzbDrone.Core.Model.Xbmc;
|
using NzbDrone.Core.Model.Xbmc;
|
||||||
using NzbDrone.Core.Providers.Xbmc;
|
using NzbDrone.Core.Providers.Xbmc;
|
||||||
using NzbDrone.Core.Repository;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers
|
namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Repository.Search
|
|
||||||
{
|
|
||||||
public class SearchHistory
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int SeriesId { get; set; }
|
|
||||||
public int? SeasonNumber { get; set; }
|
|
||||||
public int? EpisodeId { get; set; }
|
|
||||||
public DateTime SearchTime { get; set; }
|
|
||||||
public bool SuccessfulDownload { get; set; }
|
|
||||||
|
|
||||||
public List<SearchHistoryItem> SearchHistoryItems { get; set; }
|
|
||||||
|
|
||||||
public List<int> Successes { get; set; }
|
|
||||||
|
|
||||||
public string SeriesTitle { get; set; }
|
|
||||||
|
|
||||||
public bool IsDaily { get; set; }
|
|
||||||
|
|
||||||
public int? EpisodeNumber { get; set; }
|
|
||||||
|
|
||||||
public string EpisodeTitle { get; set; }
|
|
||||||
|
|
||||||
public DateTime AirDate { get; set; }
|
|
||||||
|
|
||||||
public int TotalItems { get; set; }
|
|
||||||
|
|
||||||
public int SuccessfulCount { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
using System;
|
|
||||||
using NzbDrone.Core.DecisionEngine;
|
|
||||||
using NzbDrone.Core.Model;
|
|
||||||
using NzbDrone.Core.Qualities;
|
|
||||||
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Repository.Search
|
|
||||||
{
|
|
||||||
public class SearchHistoryItem
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int SearchHistoryId { get; set; }
|
|
||||||
public string ReportTitle { get; set; }
|
|
||||||
public string Indexer { get; set; }
|
|
||||||
public string NzbUrl { get; set; }
|
|
||||||
public string NzbInfoUrl { get; set; }
|
|
||||||
public bool Success { get; set; }
|
|
||||||
public ReportRejectionReasons SearchError { get; set; }
|
|
||||||
public Quality Quality { get; set; }
|
|
||||||
public bool Proper { get; set; }
|
|
||||||
public int Age { get; set; }
|
|
||||||
public LanguageType Language { get; set; }
|
|
||||||
public long Size { get; set; }
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return String.Format("{0} - {1} - {2}", ReportTitle, Quality, SearchError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user