private async Task <HTTPDownloader.State?> ToHttpState() { var initialURL = $"https://drive.google.com/uc?id={Id}&export=download"; var client = new Wabbajack.Lib.Http.Client(); using var response = await client.GetAsync(initialURL); if (!response.IsSuccessStatusCode) { throw new HttpException((int)response.StatusCode, response.ReasonPhrase ?? "Unknown"); } var cookies = response.GetSetCookies(); var warning = cookies.FirstOrDefault(c => c.Key.StartsWith("download_warning_")); response.Dispose(); if (warning == default) { return(new HTTPDownloader.State(initialURL) { Client = client }); } var url = $"https://drive.google.com/uc?export=download&confirm={warning.Value}&id={Id}"; var httpState = new HTTPDownloader.State(url) { Client = client }; return(httpState); }
public override async Task <bool> Download(Archive a, AbsolutePath destination) { var(uri, client) = await Utils.Log(await ManuallyDownloadFile.Create(this)).Task; var state = new HTTPDownloader.State(uri.ToString()) { Client = client }; return(await state.Download(a, destination)); }
private HTTPDownloader.State ToHttpState() { var initial_url = $"https://drive.google.com/uc?id={Id}&export=download"; var client = new HttpClient(); var result = client.GetStringSync(initial_url); var regex = new Regex("(?<=/uc\\?export=download&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, Client = client }; return(http_state); }
private async Task <HTTPDownloader.State> ToHttpState() { var initialURL = $"https://drive.google.com/uc?id={Id}&export=download"; var client = new Wabbajack.Lib.Http.Client(); using var response = await client.GetAsync(initialURL); if (!response.IsSuccessStatusCode) { throw new HttpException((int)response.StatusCode, response.ReasonPhrase); } var regex = new Regex("(?<=/uc\\?export=download&confirm=).*(?=;id=)"); var confirm = regex.Match(await response.Content.ReadAsStringAsync()); var url = $"https://drive.google.com/uc?export=download&confirm={confirm}&id={Id}"; var httpState = new HTTPDownloader.State(url) { Client = client }; return(httpState); }