queue that show for the next broadcast // (or assign it to the live one if already streaming) // php cli/set_show.php 2026-10-30 19:30 // queue it with an advertised start time (Eastern) for the main page if (PHP_SAPI !== 'cli') { http_response_code(403); exit; } require __DIR__ . '/../includes/db.php'; require __DIR__ . '/../includes/broadcasts.php'; $db = getDB(); $slug = $argv[1] ?? null; $scheduledAt = null; if (isset($argv[2])) { $scheduledAt = stationTimeToUtc($argv[2] . ' ' . ($argv[3] ?? '')); if ($scheduledAt === null) { fwrite(STDERR, "Start time must be a valid date and time like 2026-10-30 19:30 (" . STATION_TIMEZONE_LABEL . ").\n"); exit(1); } } if ($slug === null) { echo "Shows:\n"; foreach ($db->query('SELECT slug, name FROM shows ORDER BY name') as $show) { printf(" %-20s %s\n", $show['slug'], $show['name']); } $current = currentShow($db); echo "\nCurrent: " . ($current ? $current['name'] : '(none)') . (liveBroadcast($db) ? ' [live]' : ''); if ($current && $current['scheduled_at'] && !$current['started_at']) { echo ', scheduled for ' . utcToStationTime($current['scheduled_at'])->format('Y-m-d H:i') . ' ' . STATION_TIMEZONE_LABEL . " ({$current['scheduled_at']} UTC)"; } echo "\n"; exit; } $stmt = $db->prepare('SELECT id, name FROM shows WHERE slug = ?'); $stmt->execute([$slug]); $show = $stmt->fetch(); if (!$show) { fwrite(STDERR, "Unknown show '{$slug}'. Run without arguments to list shows.\n"); exit(1); } if (setBroadcastShow($db, (int)$show['id'], $scheduledAt) === 'live') { echo "Live broadcast is now {$show['name']}." . ($scheduledAt ? ' (Start time ignored.)' : '') . "\n"; } else { echo "{$show['name']} is queued for the next broadcast" . ($scheduledAt ? " at {$argv[2]} {$argv[3]} " . STATION_TIMEZONE_LABEL . " ({$scheduledAt} UTC)" : '') . ".\n"; }