From 7a7039b1f74168e2491c046e1d3a225b0f69c5ac Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 30 Apr 2023 07:09:11 +0300 Subject: [PATCH] Build download requests from indexer implementation (cherry picked from commit a0b08f6c6f106d92cdb12fbb959dd2605c22fe6a) --- .../Blackhole/TorrentBlackholeFixture.cs | 19 ++++++---- .../Blackhole/UsenetBlackholeFixture.cs | 4 +- .../DelugeTests/DelugeFixture.cs | 4 +- .../DownloadClientFixtureBase.cs | 12 ++++++ .../TorrentDownloadStationFixture.cs | 8 ++-- .../UsenetDownloadStationFixture.cs | 8 ++-- .../HadoukenTests/HadoukenFixture.cs | 6 +-- .../NzbVortexTests/NzbVortexFixture.cs | 4 +- .../NzbgetTests/NzbgetFixture.cs | 4 +- .../PneumaticProviderFixture.cs | 20 ++++++++-- .../QBittorrentTests/QBittorrentFixture.cs | 16 ++++---- .../RTorrentTests/RTorrentFixture.cs | 2 +- .../SabnzbdTests/SabnzbdFixture.cs | 6 +-- .../TransmissionTests/TransmissionFixture.cs | 12 +++--- .../UTorrentTests/UTorrentFixture.cs | 8 ++-- .../VuzeTests/VuzeFixture.cs | 12 +++--- .../Download/DownloadServiceFixture.cs | 38 +++++++++---------- .../Download/Clients/Pneumatic/Pneumatic.cs | 2 +- .../Download/DownloadClientBase.cs | 2 +- src/NzbDrone.Core/Download/DownloadService.cs | 6 ++- src/NzbDrone.Core/Download/IDownloadClient.cs | 2 +- .../Download/TorrentClientBase.cs | 14 ++++--- .../Download/UsenetClientBase.cs | 4 +- src/NzbDrone.Core/Indexers/HttpIndexerBase.cs | 5 +++ src/NzbDrone.Core/Indexers/IIndexer.cs | 2 + src/NzbDrone.Core/Indexers/IndexerBase.cs | 3 +- 26 files changed, 132 insertions(+), 91 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs index 2844229b2..31f11c30d 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/TorrentBlackholeFixture.cs @@ -151,7 +151,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole { var remoteBook = CreateRemoteBook(); - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Once()); @@ -163,9 +163,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole { GivenMagnetFilePath(); Subject.Definition.Settings.As().SaveMagnetFiles = true; + var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = null; - Subject.Download(remoteBook); + + Subject.Download(remoteBook, CreateIndexer()); + Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Never()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Never()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_magnetFilePath), Times.Once()); @@ -184,7 +187,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = null; - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Never()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Never()); @@ -199,7 +202,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = null; - Assert.Throws(() => Subject.Download(remoteBook)); + Assert.Throws(() => Subject.Download(remoteBook, CreateIndexer())); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Never()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Never()); @@ -214,7 +217,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole var remoteBook = CreateRemoteBook(); - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Once()); @@ -231,7 +234,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole var remoteBook = CreateRemoteBook(); remoteBook.Release.Title = illegalTitle; - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once()); @@ -244,7 +247,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = null; - Assert.Throws(() => Subject.Download(remoteBook)); + Assert.Throws(() => Subject.Download(remoteBook, CreateIndexer())); } [Test] @@ -318,7 +321,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole { var remoteBook = CreateRemoteBook(); - Subject.Download(remoteBook).Should().BeNull(); + Subject.Download(remoteBook, CreateIndexer()).Should().BeNull(); } } } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs index fce3fea4e..807740480 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/Blackhole/UsenetBlackholeFixture.cs @@ -123,7 +123,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole { var remoteBook = CreateRemoteBook(); - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(_filePath), Times.Once()); @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole var remoteBook = CreateRemoteBook(); remoteBook.Release.Title = illegalTitle; - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock().Verify(c => c.Get(It.Is(v => v.Url.FullUri == _downloadUrl)), Times.Once()); Mocker.GetMock().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once()); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs index a92bb2139..2462ce677 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DelugeTests/DelugeFixture.cs @@ -206,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -219,7 +219,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = magnetUrl; - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().Be(expectedHash); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs index 6014243d9..14aeb8c4b 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs @@ -2,16 +2,19 @@ using System; using System.Collections.Generic; using FluentAssertions; using Moq; +using NLog; using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Common.Http; using NzbDrone.Core.Books; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; +using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.RemotePathMappings; using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Test.IndexerTests; namespace NzbDrone.Core.Test.Download.DownloadClientTests { @@ -58,6 +61,15 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests return remoteBook; } + protected virtual IIndexer CreateIndexer() + { + return new TestIndexer(Mocker.Resolve(), + Mocker.Resolve(), + Mocker.Resolve(), + Mocker.Resolve(), + Mocker.Resolve()); + } + protected void VerifyIdentifiable(DownloadClientItem downloadClientItem) { downloadClientItem.DownloadClientInfo.Protocol.Should().Be(Subject.Protocol); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs index f75a7436d..0bdd6eb1d 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/TorrentDownloadStationFixture.cs @@ -393,7 +393,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -410,7 +410,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -426,7 +426,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -505,7 +505,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests .Setup(s => s.GetSerialNumber(_settings)) .Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException")); - Assert.Throws(Is.InstanceOf(), () => Subject.Download(remoteBook)); + Assert.Throws(Is.InstanceOf(), () => Subject.Download(remoteBook, CreateIndexer())); Mocker.GetMock() .Verify(v => v.AddTaskFromUrl(It.IsAny(), null, _settings), Times.Never()); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs index a761d5adc..eeb90c490 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadStationTests/UsenetDownloadStationFixture.cs @@ -270,7 +270,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -287,7 +287,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -382,7 +382,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests .Setup(s => s.GetSerialNumber(_settings)) .Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException")); - Assert.Throws(Is.InstanceOf(), () => Subject.Download(remoteBook)); + Assert.Throws(Is.InstanceOf(), () => Subject.Download(remoteBook, CreateIndexer())); Mocker.GetMock() .Verify(v => v.AddTaskFromUrl(It.IsAny(), null, _settings), Times.Never()); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs index efff9075a..d7495059e 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/HadoukenTests/HadoukenFixture.cs @@ -202,7 +202,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -286,7 +286,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests Mocker.GetMock() .Setup(v => v.AddTorrentUri(It.IsAny(), It.IsAny())); - var result = Subject.Download(remoteBook); + var result = Subject.Download(remoteBook, CreateIndexer()); Assert.IsFalse(result.Any(c => char.IsLower(c))); } @@ -300,7 +300,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests .Setup(v => v.AddTorrentFile(It.IsAny(), It.IsAny())) .Returns("hash"); - var result = Subject.Download(remoteBook); + var result = Subject.Download(remoteBook, CreateIndexer()); Assert.IsFalse(result.Any(c => char.IsLower(c))); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs index 17d4659cc..971c947b2 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbVortexTests/NzbVortexFixture.cs @@ -206,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -218,7 +218,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests var remoteBook = CreateRemoteBook(); - Assert.Throws(() => Subject.Download(remoteBook)); + Assert.Throws(() => Subject.Download(remoteBook, CreateIndexer())); } [Test] diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs index f430d6b7e..1e7115f63 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs @@ -345,7 +345,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -357,7 +357,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests var remoteBook = CreateRemoteBook(); - Assert.Throws(() => Subject.Download(remoteBook)); + Assert.Throws(() => Subject.Download(remoteBook, CreateIndexer())); } [Test] diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs index acfac7f95..74dfdae29 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PneumaticProviderFixture.cs @@ -3,12 +3,17 @@ using System.IO; using System.Net; using FizzWare.NBuilder; using Moq; +using NLog; using NUnit.Framework; using NzbDrone.Common.Http; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients.Pneumatic; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Test.IndexerTests; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.Download.DownloadClientTests @@ -22,6 +27,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests private string _strmFolder; private string _nzbPath; private RemoteBook _remoteBook; + private IIndexer _indexer; private DownloadClientItem _downloadClientItem; [SetUp] @@ -39,6 +45,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests _remoteBook.ParsedBookInfo = new ParsedBookInfo(); + _indexer = new TestIndexer(Mocker.Resolve(), + Mocker.Resolve(), + Mocker.Resolve(), + Mocker.Resolve(), + Mocker.Resolve()); + _downloadClientItem = Builder .CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0") .Build(); @@ -59,7 +71,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests [Test] public void should_download_file_if_it_doesnt_exist() { - Subject.Download(_remoteBook); + Subject.Download(_remoteBook, _indexer); Mocker.GetMock().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath, null), Times.Once()); } @@ -69,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests { WithFailedDownload(); - Assert.Throws(() => Subject.Download(_remoteBook)); + Assert.Throws(() => Subject.Download(_remoteBook, _indexer)); } [Test] @@ -78,7 +90,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests _remoteBook.Release.Title = "Alien Ant Farm - Discography"; _remoteBook.ParsedBookInfo.Discography = true; - Assert.Throws(() => Subject.Download(_remoteBook)); + Assert.Throws(() => Subject.Download(_remoteBook, _indexer)); } [Test] @@ -94,7 +106,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); _remoteBook.Release.Title = illegalTitle; - Subject.Download(_remoteBook); + Subject.Download(_remoteBook, _indexer); Mocker.GetMock().Verify(c => c.DownloadFile(It.IsAny(), expectedFilename, null), Times.Once()); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs index 0481544b3..87a22f788 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/QBittorrentTests/QBittorrentFixture.cs @@ -454,7 +454,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -467,7 +467,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = magnetUrl; - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().Be(expectedHash); } @@ -482,7 +482,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR"; - Assert.Throws(() => Subject.Download(remoteBook)); + Assert.Throws(() => Subject.Download(remoteBook, CreateIndexer())); } [Test] @@ -495,7 +495,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp://abc"; - Assert.DoesNotThrow(() => Subject.Download(remoteBook)); + Assert.DoesNotThrow(() => Subject.Download(remoteBook, CreateIndexer())); Mocker.GetMock() .Verify(s => s.AddTorrentFromUrl(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); @@ -509,7 +509,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock() .Verify(v => v.MoveTorrentToTopInQueue(It.IsAny(), It.IsAny()), Times.Once()); @@ -527,7 +527,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -561,7 +561,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -574,7 +574,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs index 1701a15a3..4a3d12efe 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/RTorrentTests/RTorrentFixture.cs @@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.RTorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs index db8ec3d34..4307a9b99 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/SabnzbdTests/SabnzbdFixture.cs @@ -308,7 +308,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests var remoteBook = CreateRemoteBook(); remoteBook.Release.Title = title; - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock() .Verify(v => v.DownloadNzb(It.IsAny(), filename, It.IsAny(), It.IsAny(), It.IsAny()), Times.Once()); @@ -321,7 +321,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -367,7 +367,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests .Build() .ToList(); - Subject.Download(remoteBook); + Subject.Download(remoteBook, CreateIndexer()); Mocker.GetMock() .Verify(v => v.DownloadNzb(It.IsAny(), It.IsAny(), It.IsAny(), (int)SabnzbdPriority.High, It.IsAny()), Times.Once()); diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs index f603fd602..52eed5614 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/TransmissionTests/TransmissionFixture.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -123,7 +123,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = magnetUrl; - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().Be(expectedHash); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs index f35f4dc6c..8aced935a 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/UTorrentTests/UTorrentFixture.cs @@ -234,7 +234,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -259,7 +259,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = magnetUrl; - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().Be(expectedHash); } @@ -357,7 +357,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -370,7 +370,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs index d2c4feb12..9a507ae34 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/VuzeTests/VuzeFixture.cs @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); } @@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -98,7 +98,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -131,7 +131,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests var remoteBook = CreateRemoteBook(); - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().NotBeNullOrEmpty(); @@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests var remoteBook = CreateRemoteBook(); remoteBook.Release.DownloadUrl = magnetUrl; - var id = Subject.Download(remoteBook); + var id = Subject.Download(remoteBook, CreateIndexer()); id.Should().Be(expectedHash); } diff --git a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs index c2504888f..fa0c40c7f 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadServiceFixture.cs @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_publish_on_grab_event() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())); + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())); Subject.DownloadReport(_parseResult); @@ -91,18 +91,18 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_grab_using_client() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())); + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())); Subject.DownloadReport(_parseResult); - mock.Verify(s => s.Download(It.IsAny()), Times.Once()); + mock.Verify(s => s.Download(It.IsAny(), It.IsAny()), Times.Once()); } [Test] public void Download_report_should_not_publish_on_failed_grab_event() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())) .Throws(new WebException()); Assert.Throws(() => Subject.DownloadReport(_parseResult)); @@ -114,8 +114,8 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_trigger_indexer_backoff_on_indexer_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())) + .Callback((v, indexer) => { throw new ReleaseDownloadException(v.Release, "Error", new WebException()); }); @@ -134,8 +134,8 @@ namespace NzbDrone.Core.Test.Download response.Headers["Retry-After"] = "300"; var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())) + .Callback((v, indexer) => { throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response)); }); @@ -154,8 +154,8 @@ namespace NzbDrone.Core.Test.Download response.Headers["Retry-After"] = DateTime.UtcNow.AddSeconds(300).ToString("r"); var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())) + .Callback((v, indexer) => { throw new ReleaseDownloadException(v.Release, "Error", new TooManyRequestsException(request, response)); }); @@ -171,7 +171,7 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_not_trigger_indexer_backoff_on_downloadclient_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())) .Throws(new DownloadClientException("Some Error")); Assert.Throws(() => Subject.DownloadReport(_parseResult)); @@ -184,8 +184,8 @@ namespace NzbDrone.Core.Test.Download public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error() { var mock = WithUsenetClient(); - mock.Setup(s => s.Download(It.IsAny())) - .Callback(v => + mock.Setup(s => s.Download(It.IsAny(), It.IsAny())) + .Callback((v, indexer) => { throw new ReleaseUnavailableException(v.Release, "Error", new WebException()); }); @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.Download { Assert.Throws(() => Subject.DownloadReport(_parseResult)); - Mocker.GetMock().Verify(c => c.Download(It.IsAny()), Times.Never()); + Mocker.GetMock().Verify(c => c.Download(It.IsAny(), It.IsAny()), Times.Never()); VerifyEventNotPublished(); } @@ -224,7 +224,7 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); Mocker.GetMock().Verify(c => c.GetBlockedProviders(), Times.Never()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); + mockUsenet.Verify(c => c.Download(It.IsAny(), It.IsAny()), Times.Once()); VerifyEventPublished(); } @@ -236,8 +236,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); - mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Never()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Once()); + mockTorrent.Verify(c => c.Download(It.IsAny(), It.IsAny()), Times.Never()); + mockUsenet.Verify(c => c.Download(It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -250,8 +250,8 @@ namespace NzbDrone.Core.Test.Download Subject.DownloadReport(_parseResult); - mockTorrent.Verify(c => c.Download(It.IsAny()), Times.Once()); - mockUsenet.Verify(c => c.Download(It.IsAny()), Times.Never()); + mockTorrent.Verify(c => c.Download(It.IsAny(), It.IsAny()), Times.Once()); + mockUsenet.Verify(c => c.Download(It.IsAny(), It.IsAny()), Times.Never()); } } } diff --git a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs index e414a8f10..d8953c84c 100644 --- a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs +++ b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic public override DownloadProtocol Protocol => DownloadProtocol.Usenet; - public override string Download(RemoteBook remoteBook) + public override string Download(RemoteBook remoteBook, IIndexer indexer) { var url = remoteBook.Release.DownloadUrl; var title = remoteBook.Release.Title; diff --git a/src/NzbDrone.Core/Download/DownloadClientBase.cs b/src/NzbDrone.Core/Download/DownloadClientBase.cs index f33366a9f..9531a1963 100644 --- a/src/NzbDrone.Core/Download/DownloadClientBase.cs +++ b/src/NzbDrone.Core/Download/DownloadClientBase.cs @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Download get; } - public abstract string Download(RemoteBook remoteBook); + public abstract string Download(RemoteBook remoteBook, IIndexer indexer); public abstract IEnumerable GetItems(); public virtual DownloadClientItem GetImportItem(DownloadClientItem item, DownloadClientItem previousImportAttempt) diff --git a/src/NzbDrone.Core/Download/DownloadService.cs b/src/NzbDrone.Core/Download/DownloadService.cs index 6c04674df..21ad30364 100644 --- a/src/NzbDrone.Core/Download/DownloadService.cs +++ b/src/NzbDrone.Core/Download/DownloadService.cs @@ -22,6 +22,7 @@ namespace NzbDrone.Core.Download { private readonly IProvideDownloadClient _downloadClientProvider; private readonly IDownloadClientStatusService _downloadClientStatusService; + private readonly IIndexerFactory _indexerFactory; private readonly IIndexerStatusService _indexerStatusService; private readonly IRateLimitService _rateLimitService; private readonly IEventAggregator _eventAggregator; @@ -30,6 +31,7 @@ namespace NzbDrone.Core.Download public DownloadService(IProvideDownloadClient downloadClientProvider, IDownloadClientStatusService downloadClientStatusService, + IIndexerFactory indexerFactory, IIndexerStatusService indexerStatusService, IRateLimitService rateLimitService, IEventAggregator eventAggregator, @@ -38,6 +40,7 @@ namespace NzbDrone.Core.Download { _downloadClientProvider = downloadClientProvider; _downloadClientStatusService = downloadClientStatusService; + _indexerFactory = indexerFactory; _indexerStatusService = indexerStatusService; _rateLimitService = rateLimitService; _eventAggregator = eventAggregator; @@ -60,6 +63,7 @@ namespace NzbDrone.Core.Download // Get the seed configuration for this release. remoteBook.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteBook); + var indexer = _indexerFactory.GetInstance(_indexerFactory.Get(remoteBook.Release.IndexerId)); // Limit grabs to 2 per second. if (remoteBook.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteBook.Release.DownloadUrl.StartsWith("magnet:")) @@ -71,7 +75,7 @@ namespace NzbDrone.Core.Download string downloadClientId; try { - downloadClientId = downloadClient.Download(remoteBook); + downloadClientId = downloadClient.Download(remoteBook, indexer); _downloadClientStatusService.RecordSuccess(downloadClient.Definition.Id); _indexerStatusService.RecordSuccess(remoteBook.Release.IndexerId); } diff --git a/src/NzbDrone.Core/Download/IDownloadClient.cs b/src/NzbDrone.Core/Download/IDownloadClient.cs index 11537a86e..711c10209 100644 --- a/src/NzbDrone.Core/Download/IDownloadClient.cs +++ b/src/NzbDrone.Core/Download/IDownloadClient.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Download public interface IDownloadClient : IProvider { DownloadProtocol Protocol { get; } - string Download(RemoteBook remoteBook); + string Download(RemoteBook remoteBook, IIndexer indexer); IEnumerable GetItems(); DownloadClientItem GetImportItem(DownloadClientItem item, DownloadClientItem previousImportAttempt); void RemoveItem(DownloadClientItem item, bool deleteData); diff --git a/src/NzbDrone.Core/Download/TorrentClientBase.cs b/src/NzbDrone.Core/Download/TorrentClientBase.cs index 531bac025..77f29cc9f 100644 --- a/src/NzbDrone.Core/Download/TorrentClientBase.cs +++ b/src/NzbDrone.Core/Download/TorrentClientBase.cs @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Download protected abstract string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink); protected abstract string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent); - public override string Download(RemoteBook remoteBook) + public override string Download(RemoteBook remoteBook, IIndexer indexer) { var torrentInfo = remoteBook.Release as TorrentInfo; @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Download { try { - return DownloadFromWebUrl(remoteBook, torrentUrl); + return DownloadFromWebUrl(remoteBook, indexer, torrentUrl); } catch (Exception ex) { @@ -114,20 +114,20 @@ namespace NzbDrone.Core.Download if (torrentUrl.IsNotNullOrWhiteSpace()) { - return DownloadFromWebUrl(remoteBook, torrentUrl); + return DownloadFromWebUrl(remoteBook, indexer, torrentUrl); } } return null; } - private string DownloadFromWebUrl(RemoteBook remoteBook, string torrentUrl) + private string DownloadFromWebUrl(RemoteBook remoteBook, IIndexer indexer, string torrentUrl) { byte[] torrentFile = null; try { - var request = new HttpRequest(torrentUrl); + var request = indexer.GetDownloadRequest(torrentUrl); request.RateLimitKey = remoteBook?.Release?.IndexerId.ToString(); request.Headers.Accept = "application/x-bittorrent"; request.AllowAutoRedirect = false; @@ -149,7 +149,9 @@ namespace NzbDrone.Core.Download return DownloadFromMagnetUrl(remoteBook, locationHeader); } - return DownloadFromWebUrl(remoteBook, locationHeader); + request.Url += new HttpUri(locationHeader); + + return DownloadFromWebUrl(remoteBook, indexer, request.Url.ToString()); } throw new WebException("Remote website tried to redirect without providing a location."); diff --git a/src/NzbDrone.Core/Download/UsenetClientBase.cs b/src/NzbDrone.Core/Download/UsenetClientBase.cs index a4a62744b..0b8357cd4 100644 --- a/src/NzbDrone.Core/Download/UsenetClientBase.cs +++ b/src/NzbDrone.Core/Download/UsenetClientBase.cs @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Download protected abstract string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent); - public override string Download(RemoteBook remoteBook) + public override string Download(RemoteBook remoteBook, IIndexer indexer) { var url = remoteBook.Release.DownloadUrl; var filename = FileNameBuilder.CleanFileName(remoteBook.Release.Title) + ".nzb"; @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Download try { - var request = new HttpRequest(url); + var request = indexer.GetDownloadRequest(url); request.RateLimitKey = remoteBook?.Release?.IndexerId.ToString(); // TODO: Look into moving download request handling to indexer diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 4a4581e52..b7b80bdb8 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -68,6 +68,11 @@ namespace NzbDrone.Core.Indexers return FetchReleases(g => g.GetSearchRequests(searchCriteria)); } + public override HttpRequest GetDownloadRequest(string link) + { + return new HttpRequest(link); + } + protected virtual IList FetchReleases(Func pageableRequestChainSelector, bool isRecent = false) { var releases = new List(); diff --git a/src/NzbDrone.Core/Indexers/IIndexer.cs b/src/NzbDrone.Core/Indexers/IIndexer.cs index ecd5f1531..57fcc72b3 100644 --- a/src/NzbDrone.Core/Indexers/IIndexer.cs +++ b/src/NzbDrone.Core/Indexers/IIndexer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -14,5 +15,6 @@ namespace NzbDrone.Core.Indexers IList FetchRecent(); IList Fetch(BookSearchCriteria searchCriteria); IList Fetch(AuthorSearchCriteria searchCriteria); + HttpRequest GetDownloadRequest(string link); } } diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index caf9c71fb..3a7558d17 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using FluentValidation.Results; using NLog; -using NzbDrone.Common.Extensions; +using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser; @@ -70,6 +70,7 @@ namespace NzbDrone.Core.Indexers public abstract IList Fetch(BookSearchCriteria searchCriteria); public abstract IList Fetch(AuthorSearchCriteria searchCriteria); + public abstract HttpRequest GetDownloadRequest(string link); protected virtual IList CleanupReleases(IEnumerable releases) {