public override IDownloader GetDownloader() { return(DownloadDispatcher.GetInstance <HTTPDownloader>()); }
public override IDownloader GetDownloader() { return(DownloadDispatcher.GetInstance <VectorPlexusOAuthDownloader>()); }
public override IDownloader GetDownloader() { return(DownloadDispatcher.GetInstance <GoogleDriveDownloader>()); }
public override IDownloader GetDownloader() { return(DownloadDispatcher.GetInstance <GameFileSourceDownloader>()); }
public override IDownloader GetDownloader() { return(DownloadDispatcher.GetInstance <WabbajackCDNDownloader>()); }
private async Task <Stream> ResolveDownloadStream() { var downloader = (AbstractNeedsLoginDownloader)(object)DownloadDispatcher.GetInstance <TDownloader>(); TOP: string csrfurl; if (FileID == null) { csrfurl = $"{URLPrefix}{downloader.SiteURL.Host}/files/file/{FileName}/?do=download"; } else { csrfurl = $"{URLPrefix}{downloader.SiteURL.Host}/files/file/{FileName}/?do=download&r={FileID}"; } var html = await downloader.AuthedClient.GetStringAsync(csrfurl); var pattern = new Regex("(?<=csrfKey=).*(?=[&\"\'])|(?<=csrfKey: \").*(?=[&\"\'])"); var matches = pattern.Matches(html).Cast <Match>(); var csrfKey = matches.Where(m => m.Length == 32).Select(m => m.ToString()).FirstOrDefault(); if (csrfKey == null) { return(null); } string url; if (FileID == null) { url = $"{URLPrefix}{downloader.SiteURL.Host}/files/file/{FileName}/?do=download&confirm=1&t=1&csrfKey={csrfKey}"; } else { url = $"{URLPrefix}{downloader.SiteURL.Host}/files/file/{FileName}/?do=download&r={FileID}&confirm=1&t=1&csrfKey={csrfKey}"; } var streamResult = await downloader.AuthedClient.GetAsync(url); if (streamResult.StatusCode != HttpStatusCode.OK) { Utils.Error(new InvalidOperationException(), $"{downloader.SiteName} servers reported an error for file: {FileID}"); } var content_type = streamResult.Content.Headers.ContentType; if (content_type.MediaType == "application/json") { // Sometimes LL hands back a json object telling us to wait until a certain time var times = (await streamResult.Content.ReadAsStringAsync()).FromJSONString <WaitResponse>(); var secs = times.Download - times.CurrentTime; for (int x = 0; x < secs; x++) { Utils.Status($"Waiting for {secs} at the request of {downloader.SiteName}", x * 100 / secs); await Task.Delay(1000); } Utils.Status("Retrying download"); goto TOP; } return(await streamResult.Content.ReadAsStreamAsync()); }