mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix MediaFire IsAllowed always returning true
This commit is contained in:
parent
7b72c529a9
commit
6129f2a2d3
@ -40,7 +40,8 @@ public class MediaFireDownloader : ADownloader<DTOs.DownloadStates.MediaFire>, I
|
|||||||
|
|
||||||
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
||||||
{
|
{
|
||||||
return true;
|
var mediaFireState = (DTOs.DownloadStates.MediaFire) state;
|
||||||
|
return allowList.AllowedPrefixes.Any(p => mediaFireState.Url.ToString().StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IDownloadState? Resolve(IReadOnlyDictionary<string, string> iniData)
|
public override IDownloadState? Resolve(IReadOnlyDictionary<string, string> iniData)
|
||||||
@ -105,26 +106,26 @@ public class MediaFireDownloader : ADownloader<DTOs.DownloadStates.MediaFire>, I
|
|||||||
if (!result.IsSuccessStatusCode)
|
if (!result.IsSuccessStatusCode)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (job != null)
|
if (job != null)
|
||||||
job.Size = result.Content.Headers.ContentLength ?? 0;
|
job.Size = result.Content.Headers.ContentLength ?? 0;
|
||||||
|
|
||||||
if (result.Content.Headers.ContentType!.MediaType!.StartsWith("text/html",
|
if (result.Content.Headers.ContentType!.MediaType!.StartsWith("text/html",
|
||||||
StringComparison.OrdinalIgnoreCase))
|
StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var bodyData = await result.Content.ReadAsStringAsync((CancellationToken) token);
|
var bodyData = await result.Content.ReadAsStringAsync((CancellationToken) token);
|
||||||
if (job != null)
|
if (job != null)
|
||||||
await job.Report((int) (job.Size ?? 0), (CancellationToken) token);
|
await job.Report((int) (job.Size ?? 0), (CancellationToken) token);
|
||||||
var body = new HtmlDocument();
|
var body = new HtmlDocument();
|
||||||
body.LoadHtml(bodyData);
|
body.LoadHtml(bodyData);
|
||||||
var node = body.DocumentNode.DescendantsAndSelf().FirstOrDefault(d => d.HasClass("input") && d.HasClass("popsok") &&
|
var node = body.DocumentNode.DescendantsAndSelf().FirstOrDefault(d => d.HasClass("input") && d.HasClass("popsok") &&
|
||||||
d.GetAttributeValue("aria-label", "") ==
|
d.GetAttributeValue("aria-label", "") ==
|
||||||
"Download file");
|
"Download file");
|
||||||
if (node != null)
|
if (node != null)
|
||||||
return new Uri(node.GetAttributeValue("href", "not-found"));
|
return new Uri(node.GetAttributeValue("href", "not-found"));
|
||||||
|
|
||||||
var startText = "window.location.href = '";
|
var startText = "window.location.href = '";
|
||||||
var start = body.DocumentNode.InnerHtml.IndexOf(startText, StringComparison.CurrentCultureIgnoreCase);
|
var start = body.DocumentNode.InnerHtml.IndexOf(startText, StringComparison.CurrentCultureIgnoreCase);
|
||||||
|
|
||||||
if (start != -1)
|
if (start != -1)
|
||||||
{
|
{
|
||||||
var end = body.DocumentNode.InnerHtml.IndexOf("\'", start + startText.Length,
|
var end = body.DocumentNode.InnerHtml.IndexOf("\'", start + startText.Length,
|
||||||
@ -141,4 +142,4 @@ public class MediaFireDownloader : ADownloader<DTOs.DownloadStates.MediaFire>, I
|
|||||||
{
|
{
|
||||||
return new[] {$"directURL={state.Url}"};
|
return new[] {$"directURL={state.Url}"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user