Initial implementation of TuneRipper API backend
- Add Health, Video, and Download controllers with endpoints for health checks, video details, processing, status, results, and simulated downloads - Implement IVideoService for YouTube URL validation and mock video info - Add API models for responses and job status tracking - Configure DI, CORS (BlazorPolicy), OpenAPI, and root metadata endpoint in Program.cs - Add README with usage, troubleshooting, and development notes - Minor project file cleanup and encoding fix
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TuneRipper.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class DownloadController : ControllerBase
|
||||
{
|
||||
[HttpGet("{jobId}")]
|
||||
public IActionResult DownloadFile(string jobId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(jobId))
|
||||
{
|
||||
return BadRequest("Job ID is required");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// In production, you would:
|
||||
// 1. Verify the job exists and is completed
|
||||
// 2. Get the actual file path from storage
|
||||
// 3. Return the actual file
|
||||
|
||||
// For demo purposes, return a sample response
|
||||
var sampleContent = System.Text.Encoding.UTF8.GetBytes("Sample MP3 file content - this would be actual audio data in production");
|
||||
var fileName = $"video_{jobId}.mp3";
|
||||
|
||||
return File(sampleContent, "audio/mpeg", fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Error downloading file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("info/{jobId}")]
|
||||
public IActionResult GetDownloadInfo(string jobId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(jobId))
|
||||
{
|
||||
return BadRequest("Job ID is required");
|
||||
}
|
||||
|
||||
// Return download metadata
|
||||
var info = new
|
||||
{
|
||||
jobId,
|
||||
fileName = $"video_{jobId}.mp3",
|
||||
fileSize = "3.2 MB",
|
||||
format = "MP3",
|
||||
quality = "128 kbps",
|
||||
createdAt = DateTime.UtcNow,
|
||||
expiresAt = DateTime.UtcNow.AddHours(24)
|
||||
};
|
||||
|
||||
return Ok(info);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user