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,29 @@
|
||||
<?php
|
||||
// Polls Icecast and records track history. Run from cron once a minute; each run polls
|
||||
// four times, 15 seconds apart:
|
||||
// * * * * * php /path/to/rfe/cli/poll_icecast.php
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../includes/db.php';
|
||||
require __DIR__ . '/../includes/broadcasts.php';
|
||||
|
||||
// Skip this run if the previous one is still going
|
||||
$lock = fopen(sys_get_temp_dir() . '/rfe_poll_icecast.lock', 'c');
|
||||
if (!flock($lock, LOCK_EX | LOCK_NB)) exit;
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
if ($i > 0) sleep(15);
|
||||
|
||||
$track = fetchCurrentTrack();
|
||||
if ($track === false) continue; // Status API unreachable; don't treat it as the stream ending
|
||||
|
||||
try {
|
||||
recordPoll(getDB(), $track);
|
||||
} catch (Throwable $e) {
|
||||
fwrite(STDERR, date('c') . ' ' . $e->getMessage() . "\n");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user