Spaces:
Sleeping
Sleeping
Download src/ClipForge.Api/Endpoints/ScriptEndpoints.cs from clipeforge/app: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Api/Endpoints/ScriptEndpoints.cs
- Command line
-
hf download hf://spaces/clipeforge/app/src/ClipForge.Api/Endpoints/ScriptEndpoints.cs
-
curl -L -o ScriptEndpoints.cs https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Api/Endpoints/ScriptEndpoints.cs
1.67 kB
| using ClipForge.Contracts.Requests; | |
| using ClipForge.Contracts.Responses; | |
| using ClipForge.Core.Interfaces; | |
| using ClipForge.Core.Interfaces.Services; | |
| namespace ClipForge.Api.Endpoints; | |
| public static class ScriptEndpoints | |
| { | |
| public static void MapScriptEndpoints(this WebApplication app) | |
| { | |
| var group = app.MapGroup("/api/scripts").WithTags("Scripts"); | |
| group.MapPost("/generate", async (GenerateScriptRequest request, IScriptGenerationService service) => | |
| { | |
| var script = await service.GenerateScriptAsync(request.IdeaId); | |
| return Results.Ok(MapToResponse(script)); | |
| }); | |
| group.MapGet("/", async (IVideoScriptRepository repository) => | |
| { | |
| var scripts = await repository.GetAllAsync(); | |
| return Results.Ok(scripts.Select(MapToResponse)); | |
| }); | |
| group.MapGet("/{id:guid}", async (Guid id, IVideoScriptRepository repository) => | |
| { | |
| var script = await repository.GetByIdAsync(id); | |
| return script is null ? Results.NotFound() : Results.Ok(MapToResponse(script)); | |
| }); | |
| group.MapGet("/idea/{ideaId:guid}", async (Guid ideaId, IVideoScriptRepository repository) => | |
| { | |
| var script = await repository.GetByIdeaIdAsync(ideaId); | |
| return script is null ? Results.NotFound() : Results.Ok(MapToResponse(script)); | |
| }); | |
| } | |
| private static VideoScriptResponse MapToResponse(ClipForge.Core.Entities.VideoScript script) => new( | |
| script.Id, script.VideoIdeaId, script.ScriptText, script.Scenes, | |
| script.EstimatedDurationSeconds, script.Tone, script.Language, script.CreatedAt); | |
| } | |