Proxy Nzb/Torrent Downloads thru Prowlarr

This commit is contained in:
Qstick
2021-02-15 23:33:13 -05:00
parent da60543c72
commit a080bf1c6c
14 changed files with 435 additions and 6 deletions

View File

@@ -9,8 +9,10 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Http.CloudFlare;
using NzbDrone.Core.Indexers.Events;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
@@ -89,6 +91,32 @@ namespace NzbDrone.Core.Indexers
return FetchReleases(g => SetCookieFunctions(g).GetSearchRequests(searchCriteria));
}
public override byte[] Download(HttpUri link)
{
Cookies = GetCookies();
var requestBuilder = new HttpRequestBuilder(link.FullUri);
if (Cookies != null)
{
requestBuilder.SetCookies(Cookies);
}
var downloadBytes = Array.Empty<byte>();
try
{
downloadBytes = _httpClient.Execute(requestBuilder.Build()).ResponseData;
}
catch (Exception)
{
_indexerStatusService.RecordFailure(Definition.Id);
_logger.Error("Download failed");
}
return downloadBytes;
}
protected IIndexerRequestGenerator SetCookieFunctions(IIndexerRequestGenerator generator)
{
//A func ensures cookies are always updated to the latest. This way, the first page could update the cookies and then can be reused by the second page.