|
|
|
@ -14,6 +14,7 @@ public partial record ExportRequest(
|
|
|
|
|
Guild Guild,
|
|
|
|
|
Channel Channel,
|
|
|
|
|
string OutputPath,
|
|
|
|
|
string? AssetsPath,
|
|
|
|
|
ExportFormat Format,
|
|
|
|
|
Snowflake? After,
|
|
|
|
|
Snowflake? Before,
|
|
|
|
@ -36,7 +37,18 @@ public partial record ExportRequest(
|
|
|
|
|
|
|
|
|
|
public string OutputBaseDirPath => Path.GetDirectoryName(OutputBaseFilePath) ?? OutputPath;
|
|
|
|
|
|
|
|
|
|
public string OutputAssetsDirPath => $"{OutputBaseFilePath}_Files{Path.DirectorySeparatorChar}";
|
|
|
|
|
private string? _outputAssetsDirPath;
|
|
|
|
|
public string OutputAssetsDirPath => _outputAssetsDirPath ??= (
|
|
|
|
|
AssetsPath is not null
|
|
|
|
|
? EvaluateTemplateTokens(
|
|
|
|
|
AssetsPath,
|
|
|
|
|
Guild,
|
|
|
|
|
Channel,
|
|
|
|
|
After,
|
|
|
|
|
Before
|
|
|
|
|
)
|
|
|
|
|
: $"{OutputBaseFilePath}_Files{Path.DirectorySeparatorChar}"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial record ExportRequest
|
|
|
|
@ -83,17 +95,15 @@ public partial record ExportRequest
|
|
|
|
|
return PathEx.EscapeFileName(buffer.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetOutputBaseFilePath(
|
|
|
|
|
private static string EvaluateTemplateTokens(
|
|
|
|
|
string path,
|
|
|
|
|
Guild guild,
|
|
|
|
|
Channel channel,
|
|
|
|
|
string outputPath,
|
|
|
|
|
ExportFormat format,
|
|
|
|
|
Snowflake? after = null,
|
|
|
|
|
Snowflake? before = null)
|
|
|
|
|
Snowflake? after,
|
|
|
|
|
Snowflake? before)
|
|
|
|
|
{
|
|
|
|
|
// Format path
|
|
|
|
|
var actualOutputPath = Regex.Replace(
|
|
|
|
|
outputPath,
|
|
|
|
|
return Regex.Replace(
|
|
|
|
|
path,
|
|
|
|
|
"%.",
|
|
|
|
|
m => PathEx.EscapeFileName(m.Value switch
|
|
|
|
|
{
|
|
|
|
@ -110,8 +120,18 @@ public partial record ExportRequest
|
|
|
|
|
"%d" => DateTimeOffset.Now.ToString("yyyy-MM-dd"),
|
|
|
|
|
"%%" => "%",
|
|
|
|
|
_ => m.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetOutputBaseFilePath(
|
|
|
|
|
Guild guild,
|
|
|
|
|
Channel channel,
|
|
|
|
|
string outputPath,
|
|
|
|
|
ExportFormat format,
|
|
|
|
|
Snowflake? after = null,
|
|
|
|
|
Snowflake? before = null)
|
|
|
|
|
{
|
|
|
|
|
var actualOutputPath = EvaluateTemplateTokens(outputPath, guild, channel, after, before);
|
|
|
|
|
|
|
|
|
|
// Output is a directory
|
|
|
|
|
if (Directory.Exists(actualOutputPath) || string.IsNullOrWhiteSpace(Path.GetExtension(actualOutputPath)))
|
|
|
|
|