From d95839e5dfa2ba1e12d96ce9ee615e1625d257ec Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 5 Jun 2023 20:36:01 +0200 Subject: [PATCH] Chromium Version and Dependencies --- Dockerfile | 1 + Tranga/Connectors/Mangasee.cs | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index f73a225..9b169dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,5 @@ FROM mcr.microsoft.com/dotnet/aspnet:7.0 as runtime WORKDIR /publish COPY --from=build-env /publish . EXPOSE 80 +RUN apt-get update && apt-get install -y libx11-6 libx11-xcb1 libatk1.0-0 libgtk-3-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 libxshmfence1 libnss3 ENTRYPOINT ["dotnet", "/publish/Tranga-API.dll"] diff --git a/Tranga/Connectors/Mangasee.cs b/Tranga/Connectors/Mangasee.cs index 369df57..59851e8 100644 --- a/Tranga/Connectors/Mangasee.cs +++ b/Tranga/Connectors/Mangasee.cs @@ -12,7 +12,8 @@ namespace Tranga.Connectors; public class Mangasee : Connector { public override string name { get; } - private IBrowser? browser = null; + private IBrowser? _browser = null; + private const string ChromiumVersion = "1153303"; public Mangasee(string downloadLocation, string imageCachePath, Logger? logger) : base(downloadLocation, imageCachePath, logger) @@ -29,8 +30,14 @@ public class Mangasee : Connector private async void DownloadBrowser() { - logger?.WriteLine(this.GetType().ToString(), "Downloading headless browser"); BrowserFetcher browserFetcher = new BrowserFetcher(); + if (browserFetcher.LocalRevisions().Contains(ChromiumVersion)) + return; + else + foreach(string rev in browserFetcher.LocalRevisions()) + browserFetcher.Remove(rev); + + logger?.WriteLine(this.GetType().ToString(), "Downloading headless browser"); DateTime last = DateTime.Now.Subtract(TimeSpan.FromSeconds(5)); browserFetcher.DownloadProgressChanged += async (sender, args) => { @@ -46,16 +53,21 @@ public class Mangasee : Connector } }; - if (!browserFetcher.CanDownloadAsync(BrowserFetcher.DefaultChromiumRevision).Result) + if (!browserFetcher.CanDownloadAsync(ChromiumVersion).Result) { - logger?.WriteLine(this.GetType().ToString(), "Can't download"); + logger?.WriteLine(this.GetType().ToString(), $"Can't download browser version {ChromiumVersion}"); return; } - await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision); - this.browser = await Puppeteer.LaunchAsync(new LaunchOptions + await browserFetcher.DownloadAsync(ChromiumVersion); + this._browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, - ExecutablePath = browserFetcher.GetExecutablePath(BrowserFetcher.DefaultChromiumRevision) + ExecutablePath = browserFetcher.GetExecutablePath(ChromiumVersion), + Args = new [] { + "--disable-gpu", + "--disable-dev-shm-usage", + "--disable-setuid-sandbox", + "--no-sandbox"} }); } @@ -191,13 +203,13 @@ public class Mangasee : Connector public override void DownloadChapter(Publication publication, Chapter chapter, DownloadChapterTask parentTask) { - while (this.browser is null) + while (this._browser is null) { logger?.WriteLine(this.GetType().ToString(), "Waiting for headless browser to download..."); Thread.Sleep(1000); } - IPage page = browser.NewPageAsync().Result; + IPage page = _browser.NewPageAsync().Result; IResponse response = page.GoToAsync(chapter.url).Result; if (response.Ok) {