Fixed MediafireDownloader not handling direct links

This commit is contained in:
erri120 2020-07-19 20:58:40 +02:00
parent c3b11e788e
commit 870092d52d
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135

View File

@ -50,11 +50,21 @@ namespace Wabbajack.Lib.Downloaders
private async Task<HTTPDownloader.State?> Resolve()
{
var client = new Wabbajack.Lib.Http.Client();
var body = await client.GetHtmlAsync(Url);
var node = body.DocumentNode.DescendantsAndSelf().First(d => d.HasClass("input") && d.HasClass("popsok") &&
d.GetAttributeValue("aria-label", "") == "Download file");
return new HTTPDownloader.State(node.GetAttributeValue("href", "not-found"));
var client = new Http.Client();
var result = await client.GetAsync(Url, HttpCompletionOption.ResponseHeadersRead);
if (!result.IsSuccessStatusCode)
return null;
if (result.Content.Headers.ContentType.MediaType.StartsWith("text/html",
StringComparison.OrdinalIgnoreCase))
{
var body = await client.GetHtmlAsync(Url);
var node = body.DocumentNode.DescendantsAndSelf().First(d => d.HasClass("input") && d.HasClass("popsok") &&
d.GetAttributeValue("aria-label", "") == "Download file");
return new HTTPDownloader.State(node.GetAttributeValue("href", "not-found"));
}
return new HTTPDownloader.State(Url);
}
public override IDownloader GetDownloader()