From 28b523b504b438516f6a3621daca22ac35df36d5 Mon Sep 17 00:00:00 2001 From: Mitchell Cash Date: Sun, 11 Jun 2017 17:30:51 +1000 Subject: [PATCH] Fixed: Follow 301 redirects when fetching torrents (#1653) Closes #1564 --- src/NzbDrone.Core/Download/TorrentClientBase.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Download/TorrentClientBase.cs b/src/NzbDrone.Core/Download/TorrentClientBase.cs index 70681f992..9ad0e0bda 100644 --- a/src/NzbDrone.Core/Download/TorrentClientBase.cs +++ b/src/NzbDrone.Core/Download/TorrentClientBase.cs @@ -33,7 +33,7 @@ protected TorrentClientBase(ITorrentFileInfoReader torrentFileInfoReader, _httpClient = httpClient; _torrentFileInfoReader = torrentFileInfoReader; } - + public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public virtual bool PreferTorrentFile => false; @@ -149,7 +149,7 @@ public override string Download(RemoteEpisode remoteMovie) { magnetUrl = torrentInfo.MagnetUrl; } - + if (PreferTorrentFile) { if (torrentUrl.IsNotNullOrWhiteSpace()) @@ -221,7 +221,9 @@ private string DownloadFromWebUrl(RemoteMovie remoteEpisode, string torrentUrl) var response = _httpClient.Get(request); - if (response.StatusCode == HttpStatusCode.SeeOther || response.StatusCode == HttpStatusCode.Found) + if (response.StatusCode == HttpStatusCode.MovedPermanently || + response.StatusCode == HttpStatusCode.Found || + response.StatusCode == HttpStatusCode.SeeOther) { var locationHeader = response.Headers.GetSingleValue("Location"); @@ -321,7 +323,9 @@ private string DownloadFromWebUrl(RemoteEpisode remoteEpisode, string torrentUrl var response = _httpClient.Get(request); - if (response.StatusCode == HttpStatusCode.SeeOther || response.StatusCode == HttpStatusCode.Found) + if (response.StatusCode == HttpStatusCode.MovedPermanently || + response.StatusCode == HttpStatusCode.Found || + response.StatusCode == HttpStatusCode.SeeOther) { var locationHeader = response.Headers.GetSingleValue("Location");