diff --git a/MoxfieldPriceScraper/MoxfieldScraper.cs b/MoxfieldPriceScraper/MoxfieldScraper.cs index 55b2390..3850446 100644 --- a/MoxfieldPriceScraper/MoxfieldScraper.cs +++ b/MoxfieldPriceScraper/MoxfieldScraper.cs @@ -1,5 +1,6 @@ using System.Drawing; using System.Globalization; +using System.Runtime.InteropServices; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using Serilog; @@ -60,13 +61,17 @@ public async Task ScrapeAsync(CancellationToken cancellationToken) if (!string.IsNullOrEmpty(_settings.SenderEmailAddress) && !string.IsNullOrEmpty(_settings.SenderEmailPassword) && !string.IsNullOrEmpty(_settings.ReceiverEmailAddress)) + { await EmailService.SendEmailWithEmbeddedImageAsync(_settings.SenderEmailAddress, _settings.SenderEmailPassword, _settings.ReceiverEmailAddress, $"Moxfield Scraper Success on {_deckTitle}!", $"Optimal price found for {_deckTitle}: €{finalPrice}! See attachment proof...", Path.Combine(dataDirectory, $"{_deckTitle}_proof.png")); + } else + { Log.Warning("Email notification settings are not fully configured"); + } } } @@ -103,7 +108,6 @@ protected virtual void Dispose(bool disposing) private void InitializeWebDriver() { Log.Debug("Initializing WebDriver"); - new DriverManager().SetUpDriver(new ChromeConfig()); var chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--no-sandbox"); // Bypass OS security model chromeOptions.AddArgument("--headless=new"); // Run in headless mode, without a GUI @@ -117,6 +121,12 @@ private void InitializeWebDriver() }; chromeOptions.AddUserProfilePreference("prefs", preferences); + if (RuntimeInformation.OSArchitecture == Architecture.Arm || + RuntimeInformation.OSArchitecture == Architecture.Arm64) + { + new DriverManager().SetUpDriver(new ChromeConfig()); + } + _driver = new ChromeDriver(chromeOptions); _driver.Manage().Timeouts().ImplicitWait = _elementSeekTimeout; Log.Debug("WebDriver initialized with ImplicitWait set to {Timeout}", _elementSeekTimeout); @@ -290,7 +300,10 @@ private async Task GetPrice(decimal targetPrice, int updateFrequency, C Log.Information("{Time}\tPrice Before: [€{BeforePrice}]\tNow: [€{NewPrice}]", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"), price, newPrice); price = newPrice; - if (price > targetPrice) Thread.Sleep(TimeSpan.FromSeconds(updateFrequency)); + if (price > targetPrice) + { + Thread.Sleep(TimeSpan.FromSeconds(updateFrequency)); + } } Log.Information("Optimal price found: €{Price}!", price);