mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 07:43:31 -07:00
Rename command, adjust docs
This commit is contained in:
parent
e85ca90dd4
commit
076d038c1a
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace DiscordChatExporter.Core.Exporting;
|
|||
internal partial class ExportAssetDownloader(
|
||||
string workingDirPath,
|
||||
bool reuse,
|
||||
bool useNewMediaFilePaths
|
||||
bool useNestedMediaFilePaths
|
||||
)
|
||||
{
|
||||
private static readonly AsyncKeyedLocker<string> 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}";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public partial class DashboardViewModel : ViewModelBase
|
|||
dialog.ShouldFormatMarkdown,
|
||||
dialog.ShouldDownloadAssets,
|
||||
dialog.ShouldReuseAssets,
|
||||
dialog.ShouldUseNewMediaFilePaths,
|
||||
dialog.ShouldUseNestedMediaFilePaths,
|
||||
_settingsService.Locale,
|
||||
_settingsService.IsUtcNormalizationEnabled
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.">
|
||||
<TextBlock DockPanel.Dock="Left" Text="Use new media file paths" />
|
||||
<ToggleSwitch DockPanel.Dock="Right" IsChecked="{Binding ShouldUseNewMediaFilePaths}" />
|
||||
<TextBlock DockPanel.Dock="Left" Text="Use nested media file paths" />
|
||||
<ToggleSwitch DockPanel.Dock="Right" IsChecked="{Binding ShouldUseNestedMediaFilePaths}" />
|
||||
</DockPanel>
|
||||
|
||||
<!-- Assets path -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue