From 138475f3e0e3957066a35dc2cdf13d9e8bce39fa Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 10 May 2021 22:57:04 -0400 Subject: [PATCH] Fixed: Ensure Magnet grabs are passed thru Prowlarr for stats --- src/Prowlarr.Api.V1/Indexers/NewznabController.cs | 8 +++++++- src/Prowlarr.Api.V1/Search/SearchController.cs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Prowlarr.Api.V1/Indexers/NewznabController.cs b/src/Prowlarr.Api.V1/Indexers/NewznabController.cs index 70c5be3b0..bbfbc6697 100644 --- a/src/Prowlarr.Api.V1/Indexers/NewznabController.cs +++ b/src/Prowlarr.Api.V1/Indexers/NewznabController.cs @@ -10,6 +10,7 @@ using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Parser; +using NzbDrone.Core.Parser.Model; using Prowlarr.Http.Extensions; using Prowlarr.Http.REST; @@ -72,7 +73,12 @@ namespace NzbDrone.Api.V1.Indexers foreach (var result in results.Releases) { - result.DownloadUrl = _downloadMappingService.ConvertToProxyLink(new Uri(result.DownloadUrl), request.server, indexer.Id, result.Title).ToString(); + result.DownloadUrl = result.DownloadUrl != null ? _downloadMappingService.ConvertToProxyLink(new Uri(result.DownloadUrl), request.server, indexer.Id, result.Title).ToString() : null; + + if (result.DownloadProtocol == DownloadProtocol.Torrent) + { + ((TorrentInfo)result).MagnetUrl = ((TorrentInfo)result).MagnetUrl != null ? _downloadMappingService.ConvertToProxyLink(new Uri(((TorrentInfo)result).MagnetUrl), request.server, indexer.Id, result.Title).ToString() : null; + } } return Content(results.ToXml(indexerInstance.Protocol), "application/rss+xml"); diff --git a/src/Prowlarr.Api.V1/Search/SearchController.cs b/src/Prowlarr.Api.V1/Search/SearchController.cs index 98ddc214d..d0a6c2956 100644 --- a/src/Prowlarr.Api.V1/Search/SearchController.cs +++ b/src/Prowlarr.Api.V1/Search/SearchController.cs @@ -121,7 +121,8 @@ namespace Prowlarr.Api.V1.Search var release = downloadDecision.ToResource(); _remoteReleaseCache.Set(GetCacheKey(release), downloadDecision, TimeSpan.FromMinutes(30)); - release.DownloadUrl = _downloadMappingService.ConvertToProxyLink(new Uri(release.DownloadUrl), serverUrl, release.IndexerId, release.Title).ToString(); + release.DownloadUrl = release.DownloadUrl != null ? _downloadMappingService.ConvertToProxyLink(new Uri(release.DownloadUrl), serverUrl, release.IndexerId, release.Title).ToString() : null; + release.MagnetUrl = release.MagnetUrl != null ? _downloadMappingService.ConvertToProxyLink(new Uri(release.MagnetUrl), serverUrl, release.IndexerId, release.Title).ToString() : null; result.Add(release); }