mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
Build download requests from indexer implementation
(cherry picked from commit a0b08f6c6f106d92cdb12fbb959dd2605c22fe6a) Closes #3590 Closes #3593
This commit is contained in:
parent
1ffc0cb8c1
commit
5380d78cad
26 changed files with 135 additions and 95 deletions
|
@ -152,7 +152,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Once());
|
||||
|
@ -164,9 +164,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
{
|
||||
GivenMagnetFilePath();
|
||||
Subject.Definition.Settings.As<TorrentBlackholeSettings>().SaveMagnetFiles = true;
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
Subject.Download(remoteAlbum);
|
||||
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_magnetFilePath), Times.Once());
|
||||
|
@ -185,7 +188,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Never());
|
||||
|
@ -200,7 +203,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Never());
|
||||
|
@ -215,7 +218,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Once());
|
||||
|
@ -232,7 +235,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once());
|
||||
|
@ -245,7 +248,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -319,7 +322,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum).Should().BeNull();
|
||||
Subject.Download(remoteAlbum, CreateIndexer()).Should().BeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Once());
|
||||
|
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once());
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DelugeTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
|
@ -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.Configuration;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Music;
|
||||
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 remoteAlbum;
|
||||
}
|
||||
|
||||
protected virtual IIndexer CreateIndexer()
|
||||
{
|
||||
return new TestIndexer(Mocker.Resolve<IHttpClient>(),
|
||||
Mocker.Resolve<IIndexerStatusService>(),
|
||||
Mocker.Resolve<IConfigService>(),
|
||||
Mocker.Resolve<IParsingService>(),
|
||||
Mocker.Resolve<Logger>());
|
||||
}
|
||||
|
||||
protected void VerifyIdentifiable(DownloadClientItem downloadClientItem)
|
||||
{
|
||||
downloadClientItem.DownloadClientInfo.Protocol.Should().Be(Subject.Protocol);
|
||||
|
|
|
@ -393,7 +393,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -410,7 +410,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -426,7 +426,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, 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<Exception>(), () => Subject.Download(remoteAlbum));
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
|
||||
Mocker.GetMock<IDownloadStationTaskProxy>()
|
||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -292,7 +292,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -308,7 +308,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -387,7 +387,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<Exception>(), () => Subject.Download(remoteAlbum));
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
|
||||
Mocker.GetMock<IDownloadStationTaskProxy>()
|
||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.HadoukenTests
|
|||
Mocker.GetMock<IHadoukenProxy>()
|
||||
.Setup(v => v.AddTorrentUri(It.IsAny<HadoukenSettings>(), It.IsAny<string>()));
|
||||
|
||||
var result = Subject.Download(remoteAlbum);
|
||||
var result = Subject.Download(remoteAlbum, 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<HadoukenSettings>(), It.IsAny<byte[]>()))
|
||||
.Returns("hash");
|
||||
|
||||
var result = Subject.Download(remoteAlbum);
|
||||
var result = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Assert.IsFalse(result.Any(c => char.IsLower(c)));
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbVortexTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
Assert.Throws<DownloadClientException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<DownloadClientException>(() => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -345,7 +345,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
Assert.Throws<DownloadClientRejectedReleaseException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<DownloadClientRejectedReleaseException>(() => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -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 RemoteAlbum _remoteAlbum;
|
||||
private IIndexer _indexer;
|
||||
private DownloadClientItem _downloadClientItem;
|
||||
|
||||
[SetUp]
|
||||
|
@ -39,6 +45,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
|
||||
_remoteAlbum.ParsedAlbumInfo = new ParsedAlbumInfo();
|
||||
|
||||
_indexer = new TestIndexer(Mocker.Resolve<IHttpClient>(),
|
||||
Mocker.Resolve<IIndexerStatusService>(),
|
||||
Mocker.Resolve<IConfigService>(),
|
||||
Mocker.Resolve<IParsingService>(),
|
||||
Mocker.Resolve<Logger>());
|
||||
|
||||
_downloadClientItem = Builder<DownloadClientItem>
|
||||
.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(_remoteAlbum);
|
||||
Subject.Download(_remoteAlbum, _indexer);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath), Times.Once());
|
||||
}
|
||||
|
@ -69,7 +81,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Assert.Throws<WebException>(() => Subject.Download(_remoteAlbum));
|
||||
Assert.Throws<WebException>(() => Subject.Download(_remoteAlbum, _indexer));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -78,7 +90,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
|||
_remoteAlbum.Release.Title = "Alien Ant Farm - Discography";
|
||||
_remoteAlbum.ParsedAlbumInfo.Discography = true;
|
||||
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteAlbum));
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteAlbum, _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");
|
||||
_remoteAlbum.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(_remoteAlbum);
|
||||
Subject.Download(_remoteAlbum, _indexer);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR";
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -494,7 +494,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp://abc";
|
||||
|
||||
Assert.DoesNotThrow(() => Subject.Download(remoteAlbum));
|
||||
Assert.DoesNotThrow(() => Subject.Download(remoteAlbum, CreateIndexer()));
|
||||
|
||||
Mocker.GetMock<IQBittorrentProxy>()
|
||||
.Verify(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<TorrentSeedConfiguration>(), It.IsAny<QBittorrentSettings>()), Times.Once());
|
||||
|
@ -508,7 +508,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<IQBittorrentProxy>()
|
||||
.Verify(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()), Times.Once());
|
||||
|
@ -526,7 +526,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -560,7 +560,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.QBittorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.RTorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.Title = title;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<ISabnzbdProxy>()
|
||||
.Verify(v => v.DownloadNzb(It.IsAny<byte[]>(), filename, It.IsAny<string>(), It.IsAny<int>(), It.IsAny<SabnzbdSettings>()), Times.Once());
|
||||
|
@ -320,7 +320,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
|
|||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
Mocker.GetMock<ISabnzbdProxy>()
|
||||
.Verify(v => v.DownloadNzb(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), (int)SabnzbdPriority.High, It.IsAny<SabnzbdSettings>()), Times.Once());
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -123,7 +123,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.UTorrentTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
|||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
|||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteAlbum, CreateIndexer());
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
|
@ -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<RemoteAlbum>()));
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()));
|
||||
|
||||
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<RemoteAlbum>()));
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()));
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
mock.Verify(s => s.Download(It.IsAny<RemoteAlbum>()), Times.Once());
|
||||
mock.Verify(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_not_publish_on_failed_grab_event()
|
||||
{
|
||||
var mock = WithUsenetClient();
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>()))
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()))
|
||||
.Throws(new WebException());
|
||||
|
||||
Assert.Throws<WebException>(() => 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<RemoteAlbum>()))
|
||||
.Callback<RemoteAlbum>(v =>
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()))
|
||||
.Callback<RemoteAlbum, IIndexer>((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<RemoteAlbum>()))
|
||||
.Callback<RemoteAlbum>(v =>
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()))
|
||||
.Callback<RemoteAlbum, IIndexer>((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<RemoteAlbum>()))
|
||||
.Callback<RemoteAlbum>(v =>
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()))
|
||||
.Callback<RemoteAlbum, IIndexer>((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<RemoteAlbum>()))
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()))
|
||||
.Throws(new DownloadClientException("Some Error"));
|
||||
|
||||
Assert.Throws<DownloadClientException>(() => 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<RemoteAlbum>()))
|
||||
.Callback<RemoteAlbum>(v =>
|
||||
mock.Setup(s => s.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()))
|
||||
.Callback<RemoteAlbum, IIndexer>((v, indexer) =>
|
||||
{
|
||||
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
|
||||
});
|
||||
|
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
{
|
||||
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
||||
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Never());
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Never());
|
||||
VerifyEventNotPublished<AlbumGrabbedEvent>();
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ namespace NzbDrone.Core.Test.Download
|
|||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Once());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Once());
|
||||
VerifyEventPublished<AlbumGrabbedEvent>();
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Never());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Once());
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Never());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -250,8 +250,8 @@ namespace NzbDrone.Core.Test.Download
|
|||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Once());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Never());
|
||||
mockTorrent.Verify(c => c.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Once());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>(), It.IsAny<IIndexer>()), Times.Never());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
|||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
|
||||
|
||||
public override string Download(RemoteAlbum remoteAlbum)
|
||||
public override string Download(RemoteAlbum remoteAlbum, IIndexer indexer)
|
||||
{
|
||||
var url = remoteAlbum.Release.DownloadUrl;
|
||||
var title = remoteAlbum.Release.Title;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
@ -59,7 +58,7 @@ namespace NzbDrone.Core.Download
|
|||
get;
|
||||
}
|
||||
|
||||
public abstract string Download(RemoteAlbum remoteAlbum);
|
||||
public abstract string Download(RemoteAlbum remoteAlbum, IIndexer indexer);
|
||||
public abstract IEnumerable<DownloadClientItem> GetItems();
|
||||
|
||||
public virtual DownloadClientItem GetImportItem(DownloadClientItem item, DownloadClientItem previousImportAttempt)
|
||||
|
|
|
@ -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.
|
||||
remoteAlbum.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteAlbum);
|
||||
var indexer = _indexerFactory.GetInstance(_indexerFactory.Get(remoteAlbum.Release.IndexerId));
|
||||
|
||||
// Limit grabs to 2 per second.
|
||||
if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteAlbum.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
|
@ -71,7 +75,7 @@ namespace NzbDrone.Core.Download
|
|||
string downloadClientId;
|
||||
try
|
||||
{
|
||||
downloadClientId = downloadClient.Download(remoteAlbum);
|
||||
downloadClientId = downloadClient.Download(remoteAlbum, indexer);
|
||||
_downloadClientStatusService.RecordSuccess(downloadClient.Definition.Id);
|
||||
_indexerStatusService.RecordSuccess(remoteAlbum.Release.IndexerId);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.Download
|
|||
{
|
||||
DownloadProtocol Protocol { get; }
|
||||
|
||||
string Download(RemoteAlbum remoteAlbum);
|
||||
string Download(RemoteAlbum remoteAlbum, IIndexer indexer);
|
||||
IEnumerable<DownloadClientItem> GetItems();
|
||||
DownloadClientItem GetImportItem(DownloadClientItem item, DownloadClientItem previousImportAttempt);
|
||||
void RemoveItem(DownloadClientItem item, bool deleteData);
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Download
|
|||
protected abstract string AddFromMagnetLink(RemoteAlbum remoteAlbum, string hash, string magnetLink);
|
||||
protected abstract string AddFromTorrentFile(RemoteAlbum remoteAlbum, string hash, string filename, byte[] fileContent);
|
||||
|
||||
public override string Download(RemoteAlbum remoteAlbum)
|
||||
public override string Download(RemoteAlbum remoteAlbum, IIndexer indexer)
|
||||
{
|
||||
var torrentInfo = remoteAlbum.Release as TorrentInfo;
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Download
|
|||
{
|
||||
try
|
||||
{
|
||||
return DownloadFromWebUrl(remoteAlbum, torrentUrl);
|
||||
return DownloadFromWebUrl(remoteAlbum, indexer, torrentUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -114,20 +114,20 @@ namespace NzbDrone.Core.Download
|
|||
|
||||
if (torrentUrl.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return DownloadFromWebUrl(remoteAlbum, torrentUrl);
|
||||
return DownloadFromWebUrl(remoteAlbum, indexer, torrentUrl);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string DownloadFromWebUrl(RemoteAlbum remoteAlbum, string torrentUrl)
|
||||
private string DownloadFromWebUrl(RemoteAlbum remoteAlbum, IIndexer indexer, string torrentUrl)
|
||||
{
|
||||
byte[] torrentFile = null;
|
||||
|
||||
try
|
||||
{
|
||||
var request = new HttpRequest(torrentUrl);
|
||||
var request = indexer.GetDownloadRequest(torrentUrl);
|
||||
request.RateLimitKey = remoteAlbum?.Release?.IndexerId.ToString();
|
||||
request.Headers.Accept = "application/x-bittorrent";
|
||||
request.AllowAutoRedirect = false;
|
||||
|
@ -149,7 +149,9 @@ namespace NzbDrone.Core.Download
|
|||
return DownloadFromMagnetUrl(remoteAlbum, locationHeader);
|
||||
}
|
||||
|
||||
return DownloadFromWebUrl(remoteAlbum, locationHeader);
|
||||
request.Url += new HttpUri(locationHeader);
|
||||
|
||||
return DownloadFromWebUrl(remoteAlbum, indexer, request.Url.ToString());
|
||||
}
|
||||
|
||||
throw new WebException("Remote website tried to redirect without providing a location.");
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.Download
|
|||
|
||||
protected abstract string AddFromNzbFile(RemoteAlbum remoteAlbum, string filename, byte[] fileContent);
|
||||
|
||||
public override string Download(RemoteAlbum remoteAlbum)
|
||||
public override string Download(RemoteAlbum remoteAlbum, IIndexer indexer)
|
||||
{
|
||||
var url = remoteAlbum.Release.DownloadUrl;
|
||||
var filename = FileNameBuilder.CleanFileName(remoteAlbum.Release.Title) + ".nzb";
|
||||
|
@ -44,16 +44,16 @@ namespace NzbDrone.Core.Download
|
|||
|
||||
try
|
||||
{
|
||||
var nzbDataRequest = new HttpRequest(url);
|
||||
nzbDataRequest.RateLimitKey = remoteAlbum?.Release?.IndexerId.ToString();
|
||||
var request = indexer.GetDownloadRequest(url);
|
||||
request.RateLimitKey = remoteAlbum?.Release?.IndexerId.ToString();
|
||||
|
||||
// TODO: Look into moving download request handling to indexer
|
||||
if (remoteAlbum.Release.BasicAuthString.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
nzbDataRequest.Headers.Set("Authorization", "Basic " + remoteAlbum.Release.BasicAuthString);
|
||||
request.Headers.Set("Authorization", "Basic " + remoteAlbum.Release.BasicAuthString);
|
||||
}
|
||||
|
||||
nzbData = _httpClient.Get(nzbDataRequest).ResponseData;
|
||||
nzbData = _httpClient.Get(request).ResponseData;
|
||||
|
||||
_logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteAlbum.Release.Title, nzbData.Length, url);
|
||||
}
|
||||
|
|
|
@ -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<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator, IndexerPageableRequestChain> pageableRequestChainSelector, bool isRecent = false)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
|
|
|
@ -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<ReleaseInfo> FetchRecent();
|
||||
IList<ReleaseInfo> Fetch(AlbumSearchCriteria searchCriteria);
|
||||
IList<ReleaseInfo> Fetch(ArtistSearchCriteria searchCriteria);
|
||||
HttpRequest GetDownloadRequest(string link);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ReleaseInfo> Fetch(AlbumSearchCriteria searchCriteria);
|
||||
public abstract IList<ReleaseInfo> Fetch(ArtistSearchCriteria searchCriteria);
|
||||
public abstract HttpRequest GetDownloadRequest(string link);
|
||||
|
||||
protected virtual IList<ReleaseInfo> CleanupReleases(IEnumerable<ReleaseInfo> releases)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue