mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: Magnet links with torrent blackhole
This commit is contained in:
parent
c00c207517
commit
6b9c4af591
@ -9,7 +9,9 @@
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients.TorrentBlackhole;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
||||
@ -67,6 +69,21 @@ protected void GivenCompletedItem()
|
||||
.Returns(1000000);
|
||||
}
|
||||
|
||||
protected override RemoteEpisode CreateRemoteEpisode()
|
||||
{
|
||||
var remoteEpisode = base.CreateRemoteEpisode();
|
||||
var torrentInfo = new TorrentInfo();
|
||||
|
||||
torrentInfo.Title = remoteEpisode.Release.Title;
|
||||
torrentInfo.DownloadUrl = remoteEpisode.Release.DownloadUrl;
|
||||
torrentInfo.DownloadProtocol = remoteEpisode.Release.DownloadProtocol;
|
||||
torrentInfo.MagnetUrl = "magnet:?xt=urn:btih:755248817d32b00cc853e633ecdc48e4c21bff15&dn=Series.S05E10.PROPER.HDTV.x264-DEFiNE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710";
|
||||
|
||||
remoteEpisode.Release = torrentInfo;
|
||||
|
||||
return remoteEpisode;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void completed_download_should_have_required_properties()
|
||||
{
|
||||
@ -116,6 +133,15 @@ public void Download_should_replace_illegal_characters_in_title()
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_should_throw_if_magnet_and_torrent_url_does_not_exist()
|
||||
{
|
||||
var remoteEpisode = CreateRemoteEpisode();
|
||||
remoteEpisode.Release.DownloadUrl = null;
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteEpisode));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItems_should_considered_locked_files_queued()
|
||||
{
|
||||
|
@ -51,8 +51,8 @@ public override string Download(RemoteEpisode remoteEpisode)
|
||||
|
||||
string magnetUrl = null;
|
||||
string torrentUrl = null;
|
||||
|
||||
if (remoteEpisode.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
|
||||
if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && remoteEpisode.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
{
|
||||
magnetUrl = remoteEpisode.Release.DownloadUrl;
|
||||
}
|
||||
@ -76,11 +76,16 @@ public override string Download(RemoteEpisode remoteEpisode)
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
if (torrentUrl.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ReleaseDownloadException(remoteEpisode.Release, "Magnet not supported by download client. ({0})", ex.Message);
|
||||
}
|
||||
|
||||
_logger.Debug("Magnet not supported by download client, trying torrent. ({0})", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
if (hash == null && !torrentUrl.IsNullOrWhiteSpace())
|
||||
if (hash == null && torrentUrl.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
hash = DownloadFromWebUrl(remoteEpisode, torrentUrl);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user