- admin/shows.php: list shows - admin/show_edit.php: add, edit and delete shows, with validated background image uploads saved under generated names - admin/index.php: queue the next show, switch the live show, or clear the queue - includes/broadcasts.php: setBroadcastShow() and clearQueuedShow(), shared by the dashboard and cli/set_show.php - includes/admin_layout.php: flash messages and Shows nav link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
// Sets which show is airing. Run before going live:
|
|
// php cli/set_show.php list shows and the current state
|
|
// php cli/set_show.php <slug> queue that show for the next broadcast
|
|
// (or assign it to the live one if already streaming)
|
|
|
|
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;
|
|
|
|
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]' : '') . "\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']) === 'live') {
|
|
echo "Live broadcast is now {$show['name']}.\n";
|
|
} else {
|
|
echo "{$show['name']} is queued for the next broadcast.\n";
|
|
}
|