mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-22 14:07:07 +00:00
Add option to specify download directory for assets (#989)
Co-authored-by: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
@@ -98,6 +98,20 @@ public abstract class ExportCommandBase : TokenCommandBase
|
||||
)]
|
||||
public bool ShouldReuseAssets { get; init; }
|
||||
|
||||
private readonly string? _assetsPath;
|
||||
|
||||
[CommandOption(
|
||||
"media-dir",
|
||||
Description = "Download assets to this directory."
|
||||
)]
|
||||
public string? AssetsPath
|
||||
{
|
||||
get => _assetsPath;
|
||||
// Handle ~/ in paths on Unix systems
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/pull/903
|
||||
init => _assetsPath = value is not null ? Path.GetFullPath(value) : null;
|
||||
}
|
||||
|
||||
[CommandOption(
|
||||
"dateformat",
|
||||
Description = "Format used when writing dates."
|
||||
@@ -124,6 +138,14 @@ public abstract class ExportCommandBase : TokenCommandBase
|
||||
);
|
||||
}
|
||||
|
||||
// Assets directory should only be specified when the download assets option is set
|
||||
if (!string.IsNullOrWhiteSpace(AssetsPath) && !ShouldDownloadAssets)
|
||||
{
|
||||
throw new CommandException(
|
||||
"Option --media-dir cannot be used without --media."
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure the user does not try to export all channels into a single file.
|
||||
// Output path must either be a directory, or contain template tokens.
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/799
|
||||
@@ -172,6 +194,7 @@ public abstract class ExportCommandBase : TokenCommandBase
|
||||
guild,
|
||||
channel,
|
||||
OutputPath,
|
||||
AssetsPath,
|
||||
ExportFormat,
|
||||
After,
|
||||
Before,
|
||||
|
||||
Reference in New Issue
Block a user