Add endpoint to serve legacy Gooya audio files from PVC
build-and-deploy / deploy (push) Failing after 2m49s

Implement a new API endpoint to retrieve audio files based on episode ID, checking multiple potential file paths. This allows for serving existing audio files without re-downloading them, enhancing the efficiency of audio retrieval.
This commit is contained in:
masoodafar-web
2026-10-10 01:19:48 +03:30
parent 6acfb0b9d0
commit 358f66d45b
@@ -220,6 +220,31 @@ public static class TafsirEndpoints
return Results.File(path, "audio/mpeg", enableRangeProcessing: true);
});
// Legacy Gooya files already on PVC
group.MapGet("/audio/{episodeId:guid}", async (
Guid episodeId, AppDbContext db, IConfiguration config, IWebHostEnvironment env, CancellationToken ct) =>
{
var episode = await db.Episodes.AsNoTracking().FirstOrDefaultAsync(e => e.Id == episodeId, ct);
if (episode is null) return Results.NotFound();
var audioRoot = config["AudioRoot"] ?? "/data/audio";
var relative = episode.AudioUrl.TrimStart('/').Replace('\\', '/');
var candidates = new[]
{
Path.Combine(audioRoot, relative),
Path.Combine(env.ContentRootPath, "wwwroot", relative),
Path.Combine(env.ContentRootPath, "wwwroot", "audio", Path.GetFileName(relative))
};
foreach (var path in candidates)
{
if (File.Exists(path))
return Results.File(path, "audio/mpeg", enableRangeProcessing: true);
}
return Results.NotFound();
});
return group;
}
}