feat(core): add 'unescape' filter to file name templating (#622)

This commit is contained in:
Genteure 2024-11-10 15:02:26 +08:00 committed by GitHub
parent f05d8c3c0e
commit 4a34f52d4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,7 +93,11 @@ namespace BililiveRecorder.Core.Templating
templateOptions.MemberAccessStrategy.MemberNameStrategy = MemberNameStrategies.CamelCase;
templateOptions.ValueConverters.Add(o => o is JContainer j ? new JContainerValue(j) : null);
templateOptions.Filters.AddFilter("format_qn",
static (FluidValue input, FilterArguments arguments, TemplateContext context) => new StringValue(StreamQualityNumber.MapToString((int)input.ToNumberValue())));
static (FluidValue input, FilterArguments arguments, TemplateContext context)
=> new StringValue(StreamQualityNumber.MapToString((int)input.ToNumberValue())));
templateOptions.Filters.AddFilter("unescape",
static (FluidValue input, FilterArguments arguments, TemplateContext context)
=> new StringValue(System.Net.WebUtility.HtmlDecode(input.ToStringValue())));
var context = new TemplateContext(data, templateOptions);