Fixed: (Cardigann) add headers from search block for all downloads

based on jackett c567f47ad1
pull/614/head
bakerboy448 3 years ago committed by Qstick
parent 89a1b0f534
commit 39fd9bea89

@ -714,6 +714,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
{ {
Cookies = GetCookies(); Cookies = GetCookies();
var method = HttpMethod.GET; var method = HttpMethod.GET;
var headers = new Dictionary<string, string>();
if (_definition.Download != null) if (_definition.Download != null)
{ {
@ -722,7 +723,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
AddTemplateVariablesFromUri(variables, link, ".DownloadUri"); AddTemplateVariablesFromUri(variables, link, ".DownloadUri");
var headers = ParseCustomHeaders(_definition.Search?.Headers, variables); headers = ParseCustomHeaders(_definition.Search?.Headers, variables);
HttpResponse response = null; HttpResponse response = null;
var request = new HttpRequestBuilder(link.ToString()) var request = new HttpRequestBuilder(link.ToString())
@ -753,8 +754,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
{ {
try try
{ {
headers = ParseCustomHeaders(_definition.Search?.Headers, variables);
if (!download.Infohash.UseBeforeResponse || download.Before == null || response == null) if (!download.Infohash.UseBeforeResponse || download.Before == null || response == null)
{ {
response = await HttpClient.ExecuteProxiedAsync(request, Definition); response = await HttpClient.ExecuteProxiedAsync(request, Definition);
@ -777,6 +776,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
var hashDownloadRequest = new HttpRequestBuilder(torrentLink.AbsoluteUri) var hashDownloadRequest = new HttpRequestBuilder(torrentLink.AbsoluteUri)
.SetCookies(Cookies ?? new Dictionary<string, string>()) .SetCookies(Cookies ?? new Dictionary<string, string>())
.SetHeaders(headers ?? new Dictionary<string, string>())
.Build(); .Build();
hashDownloadRequest.Method = method; hashDownloadRequest.Method = method;
@ -793,8 +793,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
} }
else if (download.Selectors != null) else if (download.Selectors != null)
{ {
headers = ParseCustomHeaders(_definition.Search?.Headers, variables);
foreach (var selector in download.Selectors) foreach (var selector in download.Selectors)
{ {
var queryselector = ApplyGoTemplateText(selector.Selector, variables); var queryselector = ApplyGoTemplateText(selector.Selector, variables);
@ -836,6 +834,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
var selectorDownloadRequest = new HttpRequestBuilder(link.AbsoluteUri) var selectorDownloadRequest = new HttpRequestBuilder(link.AbsoluteUri)
.SetCookies(Cookies ?? new Dictionary<string, string>()) .SetCookies(Cookies ?? new Dictionary<string, string>())
.SetHeaders(headers ?? new Dictionary<string, string>())
.Build(); .Build();
selectorDownloadRequest.Method = method; selectorDownloadRequest.Method = method;
@ -854,6 +853,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
var downloadRequest = new HttpRequestBuilder(link.AbsoluteUri) var downloadRequest = new HttpRequestBuilder(link.AbsoluteUri)
.SetCookies(Cookies ?? new Dictionary<string, string>()) .SetCookies(Cookies ?? new Dictionary<string, string>())
.SetHeaders(headers ?? new Dictionary<string, string>())
.Build(); .Build();
downloadRequest.Method = method; downloadRequest.Method = method;

Loading…
Cancel
Save