<?php
require_once '../config/cors.php';
require_once '../config/db.php';
require_once '../helpers/auth.php';
require_once '../cloudflare.php';

$admin = requireAdmin();
$id = $_GET['id'] ?? null;
if (!$id) sendError('ID required', 400);

$stmt = $pdo->prepare("SELECT cloudflare_input_id FROM live_inputs WHERE id = ?");
$stmt->execute([$id]);
$input = $stmt->fetch();
if (!$input) sendError('Not found', 404);

$recordings = cf_get_recordings($input['cloudflare_input_id']);
sendSuccess($recordings['result'] ?? []);
?>