diff --git a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs index 063a0ed8..7f8d7e60 100644 --- a/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs @@ -97,16 +97,16 @@ public abstract class ExportCommandBase : DiscordCommandBase [CommandOption( "reuse-media", - Description = "Reuse previously downloaded assets to avoid redundant requests." + Description = "Reuse previously downloaded assets to avoid redundant requests. " + + "Keep --media-nested consistent across runs for best results." )] public bool ShouldReuseAssets { get; init; } = false; [CommandOption( - "new-media-paths", - Description = "Saves media with a new file naming convention to prevent collisions. " - + "Duplicate media may be downloaded if consecutive runs use different values for this flag." + "media-nested", + Description = "Saves assets with a nested file naming convention, creating subdirectories for each distinct asset type." )] - public bool ShouldUseNewMediaFilePaths { get; init; } = false; + public bool ShouldUseNestedMediaFilePaths { get; init; } = false; [CommandOption( "media-dir", @@ -162,9 +162,9 @@ public abstract class ExportCommandBase : DiscordCommandBase } // New media file path can only be enabled if the download assets option is set - if (ShouldUseNewMediaFilePaths && !ShouldDownloadAssets) + if (ShouldUseNestedMediaFilePaths && !ShouldDownloadAssets) { - throw new CommandException("Option --new-media-paths cannot be used without --media."); + throw new CommandException("Option --media-nested cannot be used without --media."); } // Assets directory can only be specified if the download assets option is set @@ -283,7 +283,7 @@ public abstract class ExportCommandBase : DiscordCommandBase ShouldFormatMarkdown, ShouldDownloadAssets, ShouldReuseAssets, - ShouldUseNewMediaFilePaths, + ShouldUseNestedMediaFilePaths, Locale, IsUtcNormalizationEnabled ); diff --git a/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs b/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs index 3901f6ed..258b39ed 100644 --- a/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs +++ b/DiscordChatExporter.Core/Exporting/ExportAssetDownloader.cs @@ -16,7 +16,7 @@ namespace DiscordChatExporter.Core.Exporting; internal partial class ExportAssetDownloader( string workingDirPath, bool reuse, - bool useNewMediaFilePaths + bool useNestedMediaFilePaths ) { private static readonly AsyncKeyedLocker Locker = new(); @@ -29,7 +29,7 @@ internal partial class ExportAssetDownloader( CancellationToken cancellationToken = default ) { - var localFilePath = useNewMediaFilePaths + var localFilePath = useNestedMediaFilePaths ? GetFilePathFromUrl(url) : GetFileNameFromUrlLegacy(url); var filePath = Path.Combine(workingDirPath, localFilePath); @@ -77,7 +77,6 @@ internal partial class ExportAssetDownloader // If this isn't a Discord CDN URL, save the file to the `media/external` folder. if (!string.Equals(uri.Host, "cdn.discordapp.com", StringComparison.OrdinalIgnoreCase)) { - File.AppendAllTextAsync("external_urls.txt", $"{url}\n"); return $"external/{uri.Host}{uri.AbsolutePath}"; } diff --git a/DiscordChatExporter.Core/Exporting/ExportContext.cs b/DiscordChatExporter.Core/Exporting/ExportContext.cs index 17f1b85e..8f8a8f4f 100644 --- a/DiscordChatExporter.Core/Exporting/ExportContext.cs +++ b/DiscordChatExporter.Core/Exporting/ExportContext.cs @@ -22,7 +22,7 @@ internal class ExportContext(DiscordClient discord, ExportRequest request) private readonly ExportAssetDownloader _assetDownloader = new( request.AssetsDirPath, request.ShouldReuseAssets, - request.ShouldUseNewMediaFilePaths + request.ShouldUseNestedMediaFilePaths ); public DiscordClient Discord { get; } = discord; diff --git a/DiscordChatExporter.Core/Exporting/ExportRequest.cs b/DiscordChatExporter.Core/Exporting/ExportRequest.cs index 7883c1a4..80b6aea8 100644 --- a/DiscordChatExporter.Core/Exporting/ExportRequest.cs +++ b/DiscordChatExporter.Core/Exporting/ExportRequest.cs @@ -39,7 +39,7 @@ public partial class ExportRequest public bool ShouldReuseAssets { get; } - public bool ShouldUseNewMediaFilePaths { get; } + public bool ShouldUseNestedMediaFilePaths { get; } public string? Locale { get; } @@ -60,7 +60,7 @@ public partial class ExportRequest bool shouldFormatMarkdown, bool shouldDownloadAssets, bool shouldReuseAssets, - bool shouldUseNewMediaFilePaths, + bool shouldUseNestedMediaFilePaths, string? locale, bool isUtcNormalizationEnabled ) @@ -75,7 +75,7 @@ public partial class ExportRequest ShouldFormatMarkdown = shouldFormatMarkdown; ShouldDownloadAssets = shouldDownloadAssets; ShouldReuseAssets = shouldReuseAssets; - ShouldUseNewMediaFilePaths = shouldUseNewMediaFilePaths; + ShouldUseNestedMediaFilePaths = shouldUseNestedMediaFilePaths; Locale = locale; IsUtcNormalizationEnabled = isUtcNormalizationEnabled; diff --git a/DiscordChatExporter.Gui/Services/SettingsService.cs b/DiscordChatExporter.Gui/Services/SettingsService.cs index 2a49efdc..e5d5087d 100644 --- a/DiscordChatExporter.Gui/Services/SettingsService.cs +++ b/DiscordChatExporter.Gui/Services/SettingsService.cs @@ -67,7 +67,7 @@ public partial class SettingsService() public partial bool LastShouldReuseAssets { get; set; } [ObservableProperty] - public partial bool LastShouldUseNewMediaFilePaths { get; set; } + public partial bool LastShouldUseNestedMediaFilePaths { get; set; } [ObservableProperty] public partial string? LastAssetsDirPath { get; set; } diff --git a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs index 0abfa08a..cefd9825 100644 --- a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs @@ -276,7 +276,7 @@ public partial class DashboardViewModel : ViewModelBase dialog.ShouldFormatMarkdown, dialog.ShouldDownloadAssets, dialog.ShouldReuseAssets, - dialog.ShouldUseNewMediaFilePaths, + dialog.ShouldUseNestedMediaFilePaths, _settingsService.Locale, _settingsService.IsUtcNormalizationEnabled ); diff --git a/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs index 53a1be5e..b03e1e3a 100644 --- a/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs @@ -68,7 +68,7 @@ public partial class ExportSetupViewModel( public partial bool ShouldReuseAssets { get; set; } [ObservableProperty] - public partial bool ShouldUseNewMediaFilePaths { get; set; } + public partial bool ShouldUseNestedMediaFilePaths { get; set; } [ObservableProperty] public partial string? AssetsDirPath { get; set; } @@ -108,7 +108,7 @@ public partial class ExportSetupViewModel( ShouldFormatMarkdown = settingsService.LastShouldFormatMarkdown; ShouldDownloadAssets = settingsService.LastShouldDownloadAssets; ShouldReuseAssets = settingsService.LastShouldReuseAssets; - ShouldUseNewMediaFilePaths = settingsService.LastShouldUseNewMediaFilePaths; + ShouldUseNestedMediaFilePaths = settingsService.LastShouldUseNestedMediaFilePaths; AssetsDirPath = settingsService.LastAssetsDirPath; // Show the "advanced options" section by default if any @@ -187,7 +187,7 @@ public partial class ExportSetupViewModel( settingsService.LastShouldFormatMarkdown = ShouldFormatMarkdown; settingsService.LastShouldDownloadAssets = ShouldDownloadAssets; settingsService.LastShouldReuseAssets = ShouldReuseAssets; - settingsService.LastShouldUseNewMediaFilePaths = ShouldUseNewMediaFilePaths; + settingsService.LastShouldUseNestedMediaFilePaths = ShouldUseNestedMediaFilePaths; settingsService.LastAssetsDirPath = AssetsDirPath; Close(true); diff --git a/DiscordChatExporter.Gui/Views/Dialogs/ExportSetupView.axaml b/DiscordChatExporter.Gui/Views/Dialogs/ExportSetupView.axaml index dd7d4f34..7db836f8 100644 --- a/DiscordChatExporter.Gui/Views/Dialogs/ExportSetupView.axaml +++ b/DiscordChatExporter.Gui/Views/Dialogs/ExportSetupView.axaml @@ -280,8 +280,8 @@ IsEnabled="{Binding ShouldDownloadAssets}" LastChildFill="False" ToolTip.Tip="Uses a new organization to save media files to avoid data loss. If you change this setting from run to run, duplicate media may be downloaded."> - - + +