feat: localize quality labels and add quality template token

This commit is contained in:
2026-05-01 07:16:03 +08:00
parent 0b8f2c9775
commit f0f9ed3456
9 changed files with 147 additions and 31 deletions
@@ -52,7 +52,7 @@ public sealed class SystemSettingsDto
public string OutputDirectoryTemplate { get; set; } = "{platform}/{yyyy}/{MM}/{dd}/{anchor}";
public string OutputFileNameTemplate { get; set; } = "{HHmmss}_{anchor}_{title}_{roomId}";
public string OutputFileNameTemplate { get; set; } = "{HHmmss}_{quality}_{anchor}_{title}_{roomId}{segmentSuffix}";
public string DefaultQuality { get; set; } = "origin";
@@ -233,7 +233,7 @@ public sealed class UpdateSystemSettingsRequest
public string OutputDirectoryTemplate { get; set; } = "{platform}/{yyyy}/{MM}/{dd}/{anchor}";
public string OutputFileNameTemplate { get; set; } = "{HHmmss}_{anchor}_{title}_{roomId}";
public string OutputFileNameTemplate { get; set; } = "{HHmmss}_{quality}_{anchor}_{title}_{roomId}{segmentSuffix}";
public string DefaultQuality { get; set; } = "origin";
@@ -284,6 +284,7 @@ public sealed class RecordService
liveRoom.RoomId,
storageAnchorName,
liveRoom.Title,
streamResult.SelectedQuality,
outputFormat,
saveMode,
now);
@@ -770,6 +771,7 @@ public sealed class RecordService
string roomId,
string? anchorName,
string? title,
string selectedQuality,
RecordOutputFormat outputFormat,
RecordSaveMode saveMode,
DateTimeOffset now)
@@ -783,6 +785,7 @@ public sealed class RecordService
safeRoomId,
anchorName,
title,
selectedQuality,
localNow,
segmentSuffix: string.Empty);
var directoryPath = BuildDirectoryPath(
@@ -791,6 +794,7 @@ public sealed class RecordService
safeRoomId,
anchorName,
title,
selectedQuality,
localNow,
baseFileStem);
var fileNameStem = BuildFileNameStem(
@@ -799,6 +803,7 @@ public sealed class RecordService
safeRoomId,
anchorName,
title,
selectedQuality,
localNow,
saveMode == RecordSaveMode.Segmented ? "_%05d" : string.Empty);
var folder = Path.Combine(outputRoot, directoryPath);
@@ -838,6 +843,7 @@ public sealed class RecordService
string roomId,
string? anchorName,
string? title,
string quality,
DateTimeOffset now,
string fileStem)
{
@@ -847,6 +853,7 @@ public sealed class RecordService
roomId,
anchorName,
title,
quality,
now,
forPathSegment: true,
fileStem,
@@ -866,6 +873,7 @@ public sealed class RecordService
string roomId,
string? anchorName,
string? title,
string quality,
DateTimeOffset now,
string segmentSuffix)
{
@@ -875,6 +883,7 @@ public sealed class RecordService
roomId,
anchorName,
title,
quality,
now,
forPathSegment: false,
fileStem: string.Empty,
@@ -885,7 +894,7 @@ public sealed class RecordService
private static string EnsureSegmentSuffixTemplate(string template, RecordSaveMode saveMode)
{
var effectiveTemplate = string.IsNullOrWhiteSpace(template)
? "{HHmmss}_{anchor}_{title}_{roomId}{segmentSuffix}"
? "{HHmmss}_{quality}_{anchor}_{title}_{roomId}{segmentSuffix}"
: template.Trim();
if (saveMode != RecordSaveMode.Segmented)
@@ -908,13 +917,14 @@ public sealed class RecordService
string roomId,
string? anchorName,
string? title,
string quality,
DateTimeOffset now,
bool forPathSegment,
string fileStem,
string segmentSuffix)
{
var effectiveTemplate = string.IsNullOrWhiteSpace(template)
? (forPathSegment ? "{platform}/{yyyy}/{MM}/{dd}/{anchor}" : "{HHmmss}_{anchor}_{title}_{roomId}{segmentSuffix}")
? (forPathSegment ? "{platform}/{yyyy}/{MM}/{dd}/{anchor}" : "{HHmmss}_{quality}_{anchor}_{title}_{roomId}{segmentSuffix}")
: template;
// Path tokens must stay case-sensitive so {MM} (month) and {mm} (minute) don't collide.
@@ -924,6 +934,7 @@ public sealed class RecordService
["roomId"] = roomId,
["anchor"] = NormalizeTokenValue(anchorName, "unknown-anchor"),
["title"] = NormalizeTokenValue(title, "untitled"),
["quality"] = NormalizeTokenValue(quality, "origin"),
["fileStem"] = fileStem,
["segmentSuffix"] = segmentSuffix,
["yyyy"] = now.ToString("yyyy"),
@@ -115,7 +115,7 @@ public sealed class SystemSettingsService : ISystemSettingsService
FfmpegPath = GetValue(lookup, FfmpegPathKey, "ffmpeg"),
OutputRoot = GetValue(lookup, OutputRootKey, "records"),
OutputDirectoryTemplate = GetValue(lookup, OutputDirectoryTemplateKey, "{platform}/{yyyy}/{MM}/{dd}/{anchor}"),
OutputFileNameTemplate = GetValue(lookup, OutputFileNameTemplateKey, "{HHmmss}_{anchor}_{title}_{roomId}{segmentSuffix}"),
OutputFileNameTemplate = GetValue(lookup, OutputFileNameTemplateKey, "{HHmmss}_{quality}_{anchor}_{title}_{roomId}{segmentSuffix}"),
DefaultQuality = GetValue(lookup, DefaultQualityKey, "origin"),
DefaultOutputFormat = Enum.TryParse(GetValue(lookup, DefaultOutputFormatKey, "Mp4"), true, out RecordOutputFormat outputFormat)
? outputFormat