Added "%r" placeholder to wrap parts of the path. Wrapped parts will be set recursively. #1123. e.g.: "\%G\%r%P – %T%r\%p – %C.html"

This commit is contained in:
Paul Bobik 2023-12-06 01:14:59 +01:00
parent 174b92cbb0
commit 54dcf39981

View file

@ -153,8 +153,23 @@ public partial class ExportRequest
Channel channel, Channel channel,
Snowflake? after, Snowflake? after,
Snowflake? before Snowflake? before
) => )
Regex.Replace( {
var recursivePattern = Regex.Match(path, "%r(%.*)%r");
if (
channel.Parent?.Parent != null
&& recursivePattern.Success
&& recursivePattern.Groups.Count > 1
)
{
var groupValue = recursivePattern.Groups[1].Value;
path = path.Replace(
recursivePattern.Value,
FormatPath(groupValue, guild, channel.Parent, after, before)
);
}
return Regex.Replace(
path, path,
"%.", "%.",
m => m =>
@ -187,10 +202,12 @@ public partial class ExportRequest
.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), .ToString("yyyy-MM-dd", CultureInfo.InvariantCulture),
"%%" => "%", "%%" => "%",
"%r" => string.Empty,
_ => m.Value _ => m.Value
} }
) )
); );
}
private static string GetOutputBaseFilePath( private static string GetOutputBaseFilePath(
Guild guild, Guild guild,