Fixed: (BakaBT) Torrent downloads failing

Fixes #442
This commit is contained in:
Qstick
2021-08-19 23:37:14 -04:00
parent b46e2c6ad1
commit 1ef43c40c0
2 changed files with 20 additions and 33 deletions
@@ -46,6 +46,26 @@ namespace NzbDrone.Core.Indexers.Definitions
return new BakaBTParser(Settings, Capabilities.Categories);
}
public override async Task<byte[]> Download(Uri link)
{
var request = new HttpRequestBuilder(link.ToString())
.SetCookies(GetCookies() ?? new Dictionary<string, string>())
.Build();
var response = await _httpClient.ExecuteAsync(request, Definition);
var parser = new HtmlParser();
var dom = parser.ParseDocument(response.Content);
var downloadLink = dom.QuerySelectorAll(".download_link").First().GetAttribute("href");
if (string.IsNullOrWhiteSpace(downloadLink))
{
throw new Exception("Unable to find download link.");
}
return await base.Download(new Uri(Settings.BaseUrl + downloadLink));
}
protected override async Task DoLogin()
{
UpdateCookies(null, null);