fixup some google download links so they properly download

This commit is contained in:
Timothy Baldridge 2019-10-21 13:05:03 -06:00
parent f1e316f544
commit 1882b9227b
6 changed files with 10 additions and 6 deletions

View File

@ -46,7 +46,6 @@ namespace Wabbajack.Common
public static string AppName = "Wabbajack";
public static string HashCacheName = "Wabbajack.hash_cache";
public static HashSet<string> GameESMs = new HashSet<string>
{"Skyrim.esm", "Update.esm", "Dawnguard.esm", "HearthFires.esm", "Dragonborn.esm"};

View File

@ -76,7 +76,10 @@ namespace Wabbajack.Common
public static void Status(string msg, int progress = 0)
{
_statusFn?.Invoke(msg, progress);
if (WorkQueue.CustomReportFn != null)
WorkQueue.CustomReportFn(progress, msg);
else
_statusFn?.Invoke(msg, progress);
}

View File

@ -59,7 +59,7 @@ namespace Wabbajack.Lib.Downloaders
var regex = new Regex("(?<=/uc\\?export=download&amp;confirm=).*(?=;id=)");
var confirm = regex.Match(result);
var url = $"https://drive.google.com/uc?export=download&confirm={confirm}&id={Id}";
var http_state = new HTTPDownloader.State {Url = url};
var http_state = new HTTPDownloader.State {Url = url, Client = client};
return http_state;
}

View File

@ -55,6 +55,9 @@ namespace Wabbajack.Lib.Downloaders
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public List<string> Headers { get; set; }
[JsonIgnore]
public HttpClient Client { get; set; }
public override bool IsWhitelisted(ServerWhitelist whitelist)
{
return whitelist.AllowedPrefixes.Any(p => Url.StartsWith(p));
@ -67,7 +70,7 @@ namespace Wabbajack.Lib.Downloaders
public bool DoDownload(Archive a, string destination, bool download)
{
var client = new HttpClient();
var client = Client ?? new HttpClient();
client.DefaultRequestHeaders.Add("User-Agent", Consts.UserAgent);
if (Headers != null)

View File

@ -83,7 +83,6 @@ namespace Wabbajack.Lib
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
using (var ms = new MemoryStream())
{
var entry = ar.GetEntry("modlist.json");
using (var e = entry.Open())

View File

@ -64,7 +64,7 @@ namespace Wabbajack.UI
WorkQueue.CustomReportFn = (progress, msg) => { DownloadProgress = progress; };
var state = DownloadDispatcher.ResolveArchive(_url);
state.Download(new Archive() {Name = _downloadName}, _destination);
state.Download(new Archive {Name = _downloadName}, _destination);
_parent.Result = DownloadWindow.WindowResult.Completed;
_parent.Dispatcher.Invoke(() => _parent.Close());