- Integrate yt-dlp.exe for real YouTube audio download/conversion - Serve actual MP3 files from wwwroot/downloads via API and static files - Report real-time progress from yt-dlp to frontend - Enhance DownloadController: file serving, metadata, deletion endpoints - Update VideoController to track and return real file info/URLs - Enable static file serving in Program.cs; update API info/logging - Update Blazor frontend to use real download URLs and remove old JS logic - Add README_UPDATED.md with new workflow and troubleshooting - Improve error handling, logging, and file cleanup throughout backend - Update .gitignore for downloads and yt-dlp.exe
90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using TuneRipper.Api.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddControllers();
|
|
|
|
// Add HttpClient services
|
|
builder.Services.AddHttpClient();
|
|
|
|
// Register services
|
|
builder.Services.AddScoped<IVideoService, VideoService>();
|
|
|
|
// Add CORS for Blazor WebAssembly client
|
|
builder.Services.AddCors(options =>
|
|
{
|
|
options.AddPolicy("BlazorPolicy", policy =>
|
|
{
|
|
policy.AllowAnyOrigin()
|
|
.AllowAnyMethod()
|
|
.AllowAnyHeader();
|
|
});
|
|
});
|
|
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddOpenApi();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
// Enable static files serving (for downloading MP3 files)
|
|
app.UseStaticFiles();
|
|
|
|
// Enable CORS
|
|
app.UseCors("BlazorPolicy");
|
|
|
|
app.UseAuthorization();
|
|
|
|
// Add root endpoint with startup info
|
|
app.MapGet("/", (IWebHostEnvironment env) => new
|
|
{
|
|
service = "TuneRipper API",
|
|
version = "1.0.0",
|
|
status = "running",
|
|
timestamp = DateTime.UtcNow,
|
|
environment = env.EnvironmentName,
|
|
urls = new
|
|
{
|
|
https = "https://localhost:7160",
|
|
http = "http://localhost:5112"
|
|
},
|
|
endpoints = new
|
|
{
|
|
health = "/api/health",
|
|
video_details = "/api/video/details?url={youtubeUrl}",
|
|
process_video = "/api/video/process",
|
|
check_status = "/api/video/status/{jobId}",
|
|
get_result = "/api/video/result/{jobId}",
|
|
download = "/api/download/{jobId}",
|
|
static_files = "/downloads/{fileName}",
|
|
openapi = "/openapi/v1.json"
|
|
},
|
|
testing = new
|
|
{
|
|
httpFile = "Use api-tests.http to test endpoints",
|
|
startWith = "GET /api/health to verify API is running"
|
|
}
|
|
});
|
|
|
|
app.MapControllers();
|
|
|
|
// Log startup information
|
|
app.Logger.LogInformation("?? TuneRipper API is starting...");
|
|
app.Logger.LogInformation("?? Environment: {Environment}", app.Environment.EnvironmentName);
|
|
app.Logger.LogInformation("?? API will be available at:");
|
|
app.Logger.LogInformation(" • HTTPS: https://localhost:7160");
|
|
app.Logger.LogInformation(" • HTTP: http://localhost:5112");
|
|
app.Logger.LogInformation("?? Health check: /api/health");
|
|
app.Logger.LogInformation("?? API info: /");
|
|
app.Logger.LogInformation("?? Static files served from: /downloads/*");
|
|
|
|
app.Run();
|