Merge pull request #967 from erri120/mediafire-direct-links-fix

Fixed MediafireDownloader not handling direct links
This commit is contained in:
Timothy Baldridge 2020-07-19 20:01:20 -07:00 committed by GitHub
commit 7567bd5567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,8 @@
### Changelog
#### Version - next
* Fixed Mediafire Downloader not handling direct links
#### Version - 2.1.4.0 - **
* List ingestion now supports compression and processes on a background threaded
* Support for validation of unlisted modlists

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()