New site mostly ready.
This commit is contained in:
31
sekritnewsite/now_playing.php
Normal file
31
sekritnewsite/now_playing.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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 "No active stream found.";
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user