feat: expand platform adapters and preview tooling

This commit is contained in:
2026-05-13 19:40:43 +08:00
parent b81ead700d
commit 7a286fd619
44 changed files with 4370 additions and 115 deletions
@@ -30,12 +30,15 @@ public sealed class EventScriptService : IEventScriptService
_logger = logger;
}
public async Task RunLiveStartedAsync(LiveRoom liveRoom, DateTimeOffset occurredAt, CancellationToken cancellationToken = default)
public async Task<EventScriptExecutionResultDto?> RunLiveStartedAsync(
LiveRoom liveRoom,
DateTimeOffset occurredAt,
CancellationToken cancellationToken = default)
{
var settings = await _settingsService.GetAsync(cancellationToken);
var environment = BuildLiveRoomEnvironment(liveRoom, occurredAt);
environment["LIVE_RECORDER_EVENT"] = "live_started";
await RunAsync(
return await RunAsync(
settings.EnableEventScripts && settings.EnableLiveStartedScript,
settings.LiveStartedScriptMode,
settings.LiveStartedScriptPath,
@@ -50,12 +53,15 @@ public sealed class EventScriptService : IEventScriptService
cancellationToken);
}
public async Task RunLiveEndedAsync(LiveRoom liveRoom, DateTimeOffset occurredAt, CancellationToken cancellationToken = default)
public async Task<EventScriptExecutionResultDto?> RunLiveEndedAsync(
LiveRoom liveRoom,
DateTimeOffset occurredAt,
CancellationToken cancellationToken = default)
{
var settings = await _settingsService.GetAsync(cancellationToken);
var environment = BuildLiveRoomEnvironment(liveRoom, occurredAt);
environment["LIVE_RECORDER_EVENT"] = "live_ended";
await RunAsync(
return await RunAsync(
settings.EnableEventScripts && settings.EnableLiveEndedScript,
settings.LiveEndedScriptMode,
settings.LiveEndedScriptPath,
@@ -70,7 +76,7 @@ public sealed class EventScriptService : IEventScriptService
cancellationToken);
}
public async Task RunSegmentCompletedAsync(
public async Task<EventScriptExecutionResultDto?> RunSegmentCompletedAsync(
LiveRoom? liveRoom,
RecordSession recordSession,
RecordTask recordTask,
@@ -93,7 +99,7 @@ public sealed class EventScriptService : IEventScriptService
environment["LIVE_RECORDER_TASK_STATUS"] = recordTask.Status.ToString();
environment["LIVE_RECORDER_SESSION_STATUS"] = recordSession.Status.ToString();
await RunAsync(
return await RunAsync(
forceRun || (settings.EnableEventScripts && settings.EnableSegmentCompletedScript),
settings.SegmentCompletedScriptMode,
settings.SegmentCompletedScriptPath,
@@ -156,7 +162,15 @@ public sealed class EventScriptService : IEventScriptService
};
}
private async Task RunAsync(
private static EventScriptExecutionResultDto MapOutcome(ScriptExecutionOutcome outcome) => new()
{
Success = outcome.Success,
Message = outcome.Message,
Detail = outcome.Detail,
CustomLogOutput = outcome.CustomLogOutput
};
private async Task<EventScriptExecutionResultDto?> RunAsync(
bool enabled,
string scriptMode,
string scriptPath,
@@ -172,10 +186,10 @@ public sealed class EventScriptService : IEventScriptService
{
if (!enabled)
{
return;
return null;
}
await ExecuteAsync(
var outcome = await ExecuteAsync(
scriptMode,
scriptPath,
scriptContent,
@@ -187,6 +201,8 @@ public sealed class EventScriptService : IEventScriptService
recordSessionId,
recordTaskId,
cancellationToken);
return MapOutcome(outcome);
}
private async Task<ScriptExecutionOutcome> ExecuteAsync(