Compare commits
No commits in common. "6a20783d483434d7f5a16d755b5ef39cbe98004e" and "a629792818c8034f6f792e66a9f50bd5461f6591" have entirely different histories.
6a20783d48
...
a629792818
@ -1,6 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using HtmlAgilityPack;
|
||||
using PuppeteerSharp;
|
||||
using PuppeteerSharp.Input;
|
||||
@ -12,11 +11,10 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
private IBrowser browser { get; set; }
|
||||
private const string ChromiumVersion = "1154303";
|
||||
private const int StartTimeoutMs = 30000;
|
||||
private HttpDownloadClient _httpDownloadClient;
|
||||
|
||||
private async Task<IBrowser> DownloadBrowser()
|
||||
{
|
||||
BrowserFetcher browserFetcher = new ();
|
||||
BrowserFetcher browserFetcher = new BrowserFetcher();
|
||||
foreach(string rev in browserFetcher.LocalRevisions().Where(rev => rev != ChromiumVersion))
|
||||
browserFetcher.Remove(rev);
|
||||
if (!browserFetcher.LocalRevisions().Contains(ChromiumVersion))
|
||||
@ -60,18 +58,9 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
public ChromiumDownloadClient(GlobalBase clone) : base(clone)
|
||||
{
|
||||
this.browser = DownloadBrowser().Result;
|
||||
_httpDownloadClient = new(this);
|
||||
}
|
||||
|
||||
private readonly Regex _imageUrlRex = new(@"https?:\/\/.*\.(?:p?jpe?g|gif|a?png|bmp|avif|webp)(\?.*)?");
|
||||
internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
||||
{
|
||||
return _imageUrlRex.IsMatch(url)
|
||||
? _httpDownloadClient.MakeRequestInternal(url, referrer)
|
||||
: MakeRequestBrowser(url, referrer, clickButton);
|
||||
}
|
||||
|
||||
private RequestResult MakeRequestBrowser(string url, string? referrer = null, string? clickButton = null)
|
||||
protected override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
||||
{
|
||||
IPage page = this.browser.NewPageAsync().Result;
|
||||
page.DefaultTimeout = 10000;
|
||||
|
@ -40,6 +40,6 @@ internal abstract class DownloadClient : GlobalBase
|
||||
return result;
|
||||
}
|
||||
|
||||
internal abstract RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null);
|
||||
protected abstract RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null);
|
||||
public abstract void Close();
|
||||
}
|
Loading…
Reference in New Issue
Block a user