Add recently played tracking with shows and broadcasts
- sql/schema.sql: shows, broadcasts and played_tracks tables, seeded with the five shows - cli/poll_icecast.php: cron-run poller that records broadcasts and tracks every 15 seconds while streaming; tracks are cleared ten minutes after a broadcast ends - cli/set_show.php: queue the next show, or assign one to the live broadcast - recently_played.php: track history rows for live.php, with album art and album title linking to Last.fm - live.php: recently played list, show name in heading, and per-show header background - includes/icecast.php: Icecast parsing, album art and Last.fm helpers shared by now_playing.php and the poller - includes/db.php: use UTC for the database session Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9a1e8a33a6
commit
74dfb3c146
11 files changed
+417
-50
No files matched your search
@@ -0,0 +1,48 @@
|
||||
-- Radio Free Elsewhere database schema.
|
||||
-- Apply with: mysql -u <user> -p <database> < sql/schema.sql
|
||||
-- All DATETIME values are stored in UTC (includes/db.php sets the session time zone).
|
||||
|
||||
CREATE TABLE IF NOT EXISTS shows (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
slug VARCHAR(64) NOT NULL UNIQUE,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
-- Filename in images/backgrounds/ used as the live.php header background; NULL keeps the default
|
||||
background_image VARCHAR(255) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- One row per streaming session.
|
||||
-- Pending (queued by cli/set_show.php): started_at IS NULL
|
||||
-- Live: started_at set, ended_at IS NULL
|
||||
-- Ended: ended_at set
|
||||
CREATE TABLE IF NOT EXISTS broadcasts (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
show_id INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
started_at DATETIME NULL,
|
||||
last_seen_at DATETIME NULL,
|
||||
ended_at DATETIME NULL,
|
||||
INDEX (started_at),
|
||||
INDEX (ended_at),
|
||||
FOREIGN KEY (show_id) REFERENCES shows (id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Tracks are cleared ten minutes after their broadcast ends.
|
||||
CREATE TABLE IF NOT EXISTS played_tracks (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
broadcast_id INT UNSIGNED NOT NULL,
|
||||
played_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
artist VARCHAR(255) NOT NULL DEFAULT '',
|
||||
album VARCHAR(255) NOT NULL DEFAULT '',
|
||||
art_url VARCHAR(512) NOT NULL DEFAULT '',
|
||||
INDEX (broadcast_id, played_at),
|
||||
FOREIGN KEY (broadcast_id) REFERENCES broadcasts (id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT IGNORE INTO shows (slug, name) VALUES
|
||||
('omorains-pub', 'O''Morain''s Pub'),
|
||||
('cosmoeuphoria', 'Cosmoeuphoria'),
|
||||
('bisexual-surfers', 'Bisexual Surfers From the Twilight of Time'),
|
||||
('the-bollocks', 'The Bollocks'),
|
||||
('the-spin', 'The Spin');
|
||||
Reference in new issue
Block a user