From 73bd188699ed37c06cac8911a3fe7b4b9afa4727 Mon Sep 17 00:00:00 2001 From: whimsical-c4lic0 Date: Sat, 28 Feb 2026 00:55:51 -0600 Subject: [PATCH] Add ShowScrapeSize config option to the GUI with a warning modal --- OF DL.Core/Models/Config/Config.cs | 2 + OF DL.Core/Services/ConfigService.cs | 4 + OF DL.Gui/ViewModels/ConfigFieldViewModel.cs | 3 +- OF DL.Gui/ViewModels/MainWindowViewModel.cs | 84 +++++++++++++++++++- OF DL.Gui/Views/MainWindow.axaml | 38 +++++++++ OF DL.Gui/Views/MainWindow.axaml.cs | 1 + OF DL.Tests/Services/ConfigServiceTests.cs | 20 +++++ docs/config/all-configuration-options.md | 12 +++ docs/config/configuration.md | 1 + 9 files changed, 160 insertions(+), 5 deletions(-) diff --git a/OF DL.Core/Models/Config/Config.cs b/OF DL.Core/Models/Config/Config.cs index 4453b40..a409d0c 100644 --- a/OF DL.Core/Models/Config/Config.cs +++ b/OF DL.Core/Models/Config/Config.cs @@ -94,6 +94,8 @@ public class Config : IFileNameFormatConfig [ToggleableConfig] public bool HideMissingCdmKeysWarning { get; set; } + [ToggleableConfig] public bool HideShowScrapeSizeWarning { get; set; } + [ToggleableConfig] public bool IgnoreOwnMessages { get; set; } [ToggleableConfig] public bool DisableBrowserAuth { get; set; } diff --git a/OF DL.Core/Services/ConfigService.cs b/OF DL.Core/Services/ConfigService.cs index 018df3e..4b28534 100644 --- a/OF DL.Core/Services/ConfigService.cs +++ b/OF DL.Core/Services/ConfigService.cs @@ -241,6 +241,9 @@ public class ConfigService(ILoggingService loggingService) : IConfigService HideMissingCdmKeysWarning = bool.TryParse(hoconConfig.GetString("Appearance.HideMissingCdmKeysWarning", "false"), out bool hideMissingCdmKeysWarning) && hideMissingCdmKeysWarning, + HideShowScrapeSizeWarning = + bool.TryParse(hoconConfig.GetString("Appearance.HideShowScrapeSizeWarning", "false"), + out bool hideShowScrapeSizeWarning) && hideShowScrapeSizeWarning, // Logging/Debug Settings LoggingLevel = Enum.Parse(hoconConfig.GetString("Logging.LoggingLevel"), true) @@ -417,6 +420,7 @@ public class ConfigService(ILoggingService loggingService) : IConfigService hocon.AppendLine("Appearance {"); hocon.AppendLine($" Theme = \"{config.Theme.ToString().ToLower()}\""); hocon.AppendLine($" HideMissingCdmKeysWarning = {config.HideMissingCdmKeysWarning.ToString().ToLower()}"); + hocon.AppendLine($" HideShowScrapeSizeWarning = {config.HideShowScrapeSizeWarning.ToString().ToLower()}"); hocon.AppendLine("}"); hocon.AppendLine("# Logging/Debug Settings"); diff --git a/OF DL.Gui/ViewModels/ConfigFieldViewModel.cs b/OF DL.Gui/ViewModels/ConfigFieldViewModel.cs index bb0260a..b697b80 100644 --- a/OF DL.Gui/ViewModels/ConfigFieldViewModel.cs +++ b/OF DL.Gui/ViewModels/ConfigFieldViewModel.cs @@ -58,7 +58,8 @@ public partial class ConfigFieldViewModel : ViewModelBase [nameof(Config.RenameExistingFilesWhenCustomFormatIsSelected)] = "Rename Existing Files with Custom Formats", [nameof(Config.DownloadPath)] = "Download Folder", - [nameof(Config.HideMissingCdmKeysWarning)] = "Hide Missing CDM Keys Warning" + [nameof(Config.HideMissingCdmKeysWarning)] = "Hide Missing CDM Keys Warning", + [nameof(Config.HideShowScrapeSizeWarning)] = "Hide Show Scrape Size Warning" }; public ConfigFieldViewModel( diff --git a/OF DL.Gui/ViewModels/MainWindowViewModel.cs b/OF DL.Gui/ViewModels/MainWindowViewModel.cs index c299f9a..5c88d71 100644 --- a/OF DL.Gui/ViewModels/MainWindowViewModel.cs +++ b/OF DL.Gui/ViewModels/MainWindowViewModel.cs @@ -118,7 +118,7 @@ public partial class MainWindowViewModel( [nameof(Config.CustomDate)] = "Date used for post filtering (yyyy-MM-dd).", [nameof(Config.ShowScrapeSize)] = - "Show estimated total bytes instead of item counts while preparing downloads.", + "Warning! Enabling this option will significantly increase the scraping/downloading time. Enabling this option will show estimated total bytes instead of item counts while downloading content.", [nameof(Config.DisableTextSanitization)] = "Store post and message text as-is without XML stripping.", [nameof(Config.DownloadVideoResolution)] = @@ -159,6 +159,8 @@ public partial class MainWindowViewModel( "Choose the GUI theme.", [nameof(Config.HideMissingCdmKeysWarning)] = "Skip the missing CDM keys confirmation before downloads start.", + [nameof(Config.HideShowScrapeSizeWarning)] = + "Skip the show scrape size confirmation before downloads start.", [nameof(Config.LoggingLevel)] = "Minimum log level written to logs/OFDL.txt." }; @@ -355,6 +357,15 @@ public partial class MainWindowViewModel( [ObservableProperty] private string _missingCdmWarningMessage = string.Empty; + [ObservableProperty] + [NotifyCanExecuteChangedFor(nameof(OpenSinglePostOrMessageModalCommand))] + [NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))] + [NotifyCanExecuteChangedFor(nameof(DownloadSelectedCommand))] + [NotifyCanExecuteChangedFor(nameof(DownloadPurchasedTabCommand))] + private bool _isShowScrapeSizeWarningModalOpen; + + [ObservableProperty] private string _showScrapeSizeWarningMessage = string.Empty; + [ObservableProperty] [NotifyCanExecuteChangedFor(nameof(OpenSinglePostOrMessageModalCommand))] [NotifyCanExecuteChangedFor(nameof(SubmitSinglePostOrMessageCommand))] @@ -495,6 +506,7 @@ public partial class MainWindowViewModel( private bool _isUpdatingAllUsersSelected; private TaskCompletionSource? _missingCdmWarningCompletionSource; + private TaskCompletionSource? _showScrapeSizeWarningCompletionSource; private TaskCompletionSource? _downloadSelectionWarningCompletionSource; public async Task InitializeAsync() @@ -891,6 +903,20 @@ public partial class MainWindowViewModel( _missingCdmWarningCompletionSource?.TrySetResult(false); } + [RelayCommand] + private void ConfirmShowScrapeSizeWarning() + { + IsShowScrapeSizeWarningModalOpen = false; + _showScrapeSizeWarningCompletionSource?.TrySetResult(true); + } + + [RelayCommand] + private void CancelShowScrapeSizeWarning() + { + IsShowScrapeSizeWarningModalOpen = false; + _showScrapeSizeWarningCompletionSource?.TrySetResult(false); + } + [RelayCommand] private void ConfirmDownloadSelectionWarning() { @@ -947,6 +973,11 @@ public partial class MainWindowViewModel( return; } + if (!await EnsureShowScrapeSizeWarningConfirmedAsync()) + { + return; + } + downloadErrorLogTracker.StartSession(); IsDownloading = true; _workCancellationSource?.Dispose(); @@ -1055,6 +1086,7 @@ public partial class MainWindowViewModel( AvailableUsers.Any(user => user.IsSelected) && !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && + !IsShowScrapeSizeWarningModalOpen && !IsDownloading; private bool CanDownloadPurchasedTab() => @@ -1062,6 +1094,7 @@ public partial class MainWindowViewModel( _allUsers.Count > 0 && !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && + !IsShowScrapeSizeWarningModalOpen && !IsDownloading; private bool CanOpenSinglePostOrMessageModal() => @@ -1069,12 +1102,14 @@ public partial class MainWindowViewModel( !IsDownloading && !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && + !IsShowScrapeSizeWarningModalOpen && !IsSinglePostOrMessageModalOpen; private bool CanSubmitSinglePostOrMessage() => IsSinglePostOrMessageModalOpen && !IsDownloadSelectionWarningModalOpen && !IsMissingCdmWarningModalOpen && + !IsShowScrapeSizeWarningModalOpen && !IsDownloading && !string.IsNullOrWhiteSpace(SinglePostOrMessageUrl); @@ -1251,6 +1286,11 @@ public partial class MainWindowViewModel( return; } + if (!await EnsureShowScrapeSizeWarningConfirmedAsync()) + { + return; + } + downloadErrorLogTracker.StartSession(); IsDownloading = true; _workCancellationSource?.Dispose(); @@ -1423,6 +1463,41 @@ public partial class MainWindowViewModel( return confirmed; } + private async Task EnsureShowScrapeSizeWarningConfirmedAsync() + { + if (!configService.CurrentConfig.ShowScrapeSize || configService.CurrentConfig.HideShowScrapeSizeWarning) + { + return true; + } + + ShowScrapeSizeWarningMessage = + "Show Scrape Size is enabled.\n\n" + + "This mode estimates total bytes before downloads and can significantly increase scraping/downloading time.\n\n" + + "You can hide this warning in the future by enabling \"Hide Show Scrape Size Warning\" in the configuration settings.\n\n"; + + _showScrapeSizeWarningCompletionSource = + new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + IsShowScrapeSizeWarningModalOpen = true; + + bool confirmed; + try + { + confirmed = await _showScrapeSizeWarningCompletionSource.Task; + } + finally + { + _showScrapeSizeWarningCompletionSource = null; + IsShowScrapeSizeWarningModalOpen = false; + } + + if (!confirmed) + { + AppendLog("Download canceled after show scrape size warning."); + } + + return confirmed; + } + private async Task EnsureDownloadSelectionWarningConfirmedAsync() { bool hasEnabledMediaType = configService.CurrentConfig.DownloadVideos || @@ -1906,6 +1981,7 @@ public partial class MainWindowViewModel( { nameof(Config.Theme) => 0, nameof(Config.HideMissingCdmKeysWarning) => 1, + nameof(Config.HideShowScrapeSizeWarning) => 2, _ => 100 }; } @@ -2284,7 +2360,7 @@ public partial class MainWindowViewModel( return JsonConvert.DeserializeObject(json) ?? new Config(); } - private static void EnforceGuiOnlyConfigValues(Config config) => config.ShowScrapeSize = false; + private static void EnforceGuiOnlyConfigValues(Config config) => _ = config; private static bool IsHiddenConfigField(string propertyName) => propertyName is nameof(Config.NonInteractiveMode) @@ -2304,8 +2380,7 @@ public partial class MainWindowViewModel( or nameof(Config.DownloadStories) or nameof(Config.DownloadHighlights) or nameof(Config.DownloadMessages) - or nameof(Config.DownloadPaidMessages) - or nameof(Config.ShowScrapeSize); + or nameof(Config.DownloadPaidMessages); private static string GetConfigCategory(string propertyName) => propertyName switch @@ -2362,6 +2437,7 @@ public partial class MainWindowViewModel( nameof(Config.Theme) => "Appearance", nameof(Config.HideMissingCdmKeysWarning) => "Appearance", + nameof(Config.HideShowScrapeSizeWarning) => "Appearance", nameof(Config.LoggingLevel) => "Logging", diff --git a/OF DL.Gui/Views/MainWindow.axaml b/OF DL.Gui/Views/MainWindow.axaml index a12db02..ba0d7c2 100644 --- a/OF DL.Gui/Views/MainWindow.axaml +++ b/OF DL.Gui/Views/MainWindow.axaml @@ -1611,6 +1611,44 @@ + + + + + + + + +