Files
radio-free-elsewhere/now_playing.php
T
2026-10-30 08:37:10 -05:00

30 lines
1.2 KiB
PHP

<?php
header('Content-Type: text/html; charset=utf-8');
require __DIR__ . '/includes/icecast.php';
$track = fetchCurrentTrack();
if ($track === false) {
echo "Unable to retrieve stream information.";
} elseif ($track === null) {
echo "RFE is currently offline!<br>Please check back later!";
} else {
['title' => $title, 'artist' => $artist, 'album' => $album] = $track;
$artUrl = lookupAlbumArt($artist, $album);
if ($artUrl !== '') {
echo '<img src="' . htmlspecialchars($artUrl, ENT_QUOTES, 'UTF-8') . '" alt="Album art" style="width:100%;max-width:200px;display:block;margin-bottom:8px;border-radius:4px;">';
}
echo htmlspecialchars($title ?: 'No song metadata available', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
if ($artist !== '') echo '<br>' . htmlspecialchars($artist, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
if ($album !== '') echo '<br>' . htmlspecialchars($album, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
if ($artist !== '' && $title !== '') {
$lastfmUrl = lastfmTrackUrl($artist, $title);
echo '<br><a href="' . htmlspecialchars($lastfmUrl, ENT_QUOTES, 'UTF-8') . '" target="_blank" rel="noopener" style="color:#97C9D3;font-size:0.9em;">More on Last.fm &rarr;</a>';
}
}
?>