Add optional episode titles to queued and live broadcasts
Store an episode_title on each broadcast, settable from the dashboard or with set_show.php --title=, and show it under the show name on index.php and under the heading on live.php. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9bc9af87c7
commit
170ae6eed0
9 files changed
+67
-25
No files matched your search
@@ -38,10 +38,10 @@ function pendingBroadcast(PDO $db): ?array {
|
||||
}
|
||||
|
||||
// The show for the live broadcast, or the queued one if nothing is live yet,
|
||||
// with the broadcast's scheduled_at and started_at. Stale broadcasts are skipped as in liveBroadcast().
|
||||
// with the broadcast's scheduled_at, episode_title and started_at. Stale broadcasts are skipped as in liveBroadcast().
|
||||
function currentShow(PDO $db): ?array {
|
||||
$row = $db->query(
|
||||
'SELECT s.*, b.scheduled_at, b.started_at FROM broadcasts b
|
||||
'SELECT s.*, b.scheduled_at, b.episode_title, b.started_at FROM broadcasts b
|
||||
JOIN shows s ON s.id = b.show_id
|
||||
WHERE b.ended_at IS NULL
|
||||
AND (b.started_at IS NULL OR b.last_seen_at >= NOW() - INTERVAL ' . BROADCAST_GRACE_MINUTES . ' MINUTE)
|
||||
@@ -64,15 +64,18 @@ function utcToStationTime(string $utc): DateTimeImmutable {
|
||||
}
|
||||
|
||||
// Assigns a show to the live broadcast, or queues it for the next one if nothing is live.
|
||||
// $scheduledAt (UTC) is the advertised start time of a queued show. Returns 'live' or 'queued'.
|
||||
function setBroadcastShow(PDO $db, int $showId, ?string $scheduledAt = null): string {
|
||||
// $scheduledAt (UTC) is the advertised start time of a queued show; $episodeTitle is optional and replaces
|
||||
// any title already set (blank clears it). Returns 'live' or 'queued'.
|
||||
function setBroadcastShow(PDO $db, int $showId, ?string $scheduledAt = null, ?string $episodeTitle = null): string {
|
||||
$episodeTitle = trim((string)$episodeTitle);
|
||||
$episodeTitle = $episodeTitle === '' ? null : mb_substr($episodeTitle, 0, 255);
|
||||
$live = liveBroadcast($db);
|
||||
if ($live !== null) {
|
||||
$db->prepare('UPDATE broadcasts SET show_id = ? WHERE id = ?')->execute([$showId, $live['id']]);
|
||||
$db->prepare('UPDATE broadcasts SET show_id = ?, episode_title = ? WHERE id = ?')->execute([$showId, $episodeTitle, $live['id']]);
|
||||
return 'live';
|
||||
}
|
||||
clearQueuedShow($db);
|
||||
$db->prepare('INSERT INTO broadcasts (show_id, scheduled_at) VALUES (?, ?)')->execute([$showId, $scheduledAt]);
|
||||
$db->prepare('INSERT INTO broadcasts (show_id, scheduled_at, episode_title) VALUES (?, ?, ?)')->execute([$showId, $scheduledAt, $episodeTitle]);
|
||||
return 'queued';
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user