32 lines
963 B
PHP
32 lines
963 B
PHP
<?php
|
|
// Icecast server status URL
|
|
$icecastStatusURL = "https://radio.cyberpunklibrarian.nohost.me/status-json.xsl";
|
|
|
|
// Fetch the status JSON
|
|
$response = @file_get_contents($icecastStatusURL);
|
|
|
|
if ($response === FALSE) {
|
|
echo "Unable to retrieve stream information.";
|
|
} else {
|
|
$data = json_decode($response, true);
|
|
|
|
if (isset($data['icestats']['source'])) {
|
|
$source = $data['icestats']['source'];
|
|
|
|
// Ensure $source is treated as an array
|
|
if (!is_array($source) || isset($source['title'])) {
|
|
$currentStream = $source;
|
|
} else {
|
|
$currentStream = $source[0]; // If multiple sources exist, take the first
|
|
}
|
|
|
|
// Extract song metadata
|
|
$currentSong = isset($currentStream['title']) ? $currentStream['title'] : 'No song metadata available';
|
|
|
|
echo htmlspecialchars($currentSong);
|
|
} else {
|
|
echo "RFE is currently offline! Please check back later!";
|
|
}
|
|
}
|
|
?>
|