Jump to content

I need a Script to show the Current DJ on air (Details Below)


mrdata71
 Share

Recommended Posts

  • 4 weeks later...

im using that script

 

<?php

// First we need to make a connection to your Shoutcast server stats xml page. Change host and port of the url to yours and the sid number too if needed (default is 1).

$url = "http://149.56.234.138:8157/stats?sid=1";

$xml = simplexml_load_file($url) or die("feed not loading");

 

 

// Use SERVERGENRE instead of SONGTITLE to parse DJ name from the Genre.

// $genre = $xml->SERVERGENRE;

// echo $genre;

 

 

// Next we pull the SONGTITLE from the xml and split the variable with delimiter ":"

 

 

$songTitle = $xml->SONGTITLE;

$parts = explode(':', $songTitle);

 

 

// $parts should now contain 2 strings of text in an array if a DJ is onair, and just one if not.

// Use $parts[0] for prepended song titles and $parts[1] for appended song titles.

// For prepended (DJ name before title info), DJs must prepend in the format of "DJname: " (without "s.)

// For appended (DJ name after title info), DJs must append in the format of ":DJname" (without "s.)

// The colon is important as it is what tells us where the DJ name ends and the Song Title begins.

 

 

// Next we check if anything is in the second part of our array.

if($parts[1] == ""){

 

 

// If there is nothing in the second part of the array, we know that the Auto DJ is on.

echo "AutoDJ OnAir!";

 

 

// Instead of just saying AutoDJ OnAir, we can echo out an image based on one located in

// a folder called djimages like this

// echo "http://urban-radio.co.uk/images/jukebox.gifAuto DJ";

 

 

} else {

 

 

// If $parts[1] does have text, our DJ is on.

echo $parts[0]." OnAir";

 

 

// Instead of just saying DJ XYZ OnAir, we can echo out an image based on one located in

// a folder called djimages where the image filename is the same as the djname used like this:

// echo "djimages/".$parts[0].".jpgAuto DJ";

}

?>

 

but my question is how am i suppose to know if one of my djs are on the air?

Link to comment
Share on other sites

  • 2 months later...

can someone show me an example page of this php code working please

i have edited this code before posting

 

 

// First we need to make a connection to your Shoutcast server stats xml page. Change host and port of the url to yours and the sid number too if needed (default is 1).
$url = "http://virtual-nexus.de:8000/stats?sid=1";
$xml = simplexml_load_file($url) or die("feed not loading");

// Use SERVERGENRE instead of SONGTITLE to parse DJ name from the Genre.
// $genre = $xml->SERVERGENRE;
// echo $genre;

// Next we pull the SONGTITLE from the xml and split the variable with delimiter ":"

$songTitle = $xml->SONGTITLE;
$parts = explode(':', $songTitle);

// $parts should now contain 2 strings of text in an array if a DJ is onair, and just one if not.
// Use $parts[0] for prepended song titles and $parts[1] for appended song titles.
// For prepended (DJ name before title info), DJs must prepend in the format of "DJname: " (without "s.)
// For appended (DJ name after title info), DJs must append in the format of ":DJname" (without "s.)
// The colon is important as it is what tells us where the DJ name ends and the Song Title begins.

// Next we check if anything is in the second part of our array.
if($parts[1] == ""){ 

// If there is nothing in the second part of the array, we know that the Auto DJ is on.
echo "AutoDJ OnAir!";

// Instead of just saying AutoDJ OnAir, we can echo out an image based on one located in 
// a folder called djimages like this
// echo "djimages/jukebox.pngAuto DJ";

} else {

// If $parts[1] does have text, our DJ is on.
echo $parts[0]." OnAir";

// Instead of just saying DJ XYZ OnAir, we can echo out an image based on one located in
// a folder called djimages where the image filename is the same as the djname used like this:
// echo "djimages/jukebox.png".$parts[0].".jpgAuto DJ";
}
?>

Link to comment
Share on other sites

can someone show me an example page of this php code working please

i have edited this code before posting

 

 

// First we need to make a connection to your Shoutcast server stats xml page. Change host and port of the url to yours and the sid number too if needed (default is 1).
$url = "http://virtual-nexus.de:8000/stats?sid=1";
$xml = simplexml_load_file($url) or die("feed not loading");

// Use SERVERGENRE instead of SONGTITLE to parse DJ name from the Genre.
// $genre = $xml->SERVERGENRE;
// echo $genre;

// Next we pull the SONGTITLE from the xml and split the variable with delimiter ":"

$songTitle = $xml->SONGTITLE;
$parts = explode(':', $songTitle);

// $parts should now contain 2 strings of text in an array if a DJ is onair, and just one if not.
// Use $parts[0] for prepended song titles and $parts[1] for appended song titles.
// For prepended (DJ name before title info), DJs must prepend in the format of "DJname: " (without "s.)
// For appended (DJ name after title info), DJs must append in the format of ":DJname" (without "s.)
// The colon is important as it is what tells us where the DJ name ends and the Song Title begins.

// Next we check if anything is in the second part of our array.
if($parts[1] == ""){ 

// If there is nothing in the second part of the array, we know that the Auto DJ is on.
echo "AutoDJ OnAir!";

// Instead of just saying AutoDJ OnAir, we can echo out an image based on one located in 
// a folder called djimages like this
// echo "djimages/jukebox.pngAuto DJ";

} else {

// If $parts[1] does have text, our DJ is on.
echo $parts[0]." OnAir";

// Instead of just saying DJ XYZ OnAir, we can echo out an image based on one located in
// a folder called djimages where the image filename is the same as the djname used like this:
// echo "djimages/jukebox.png".$parts[0].".jpgAuto DJ";
}
?>

 

 

That script assumes that you show the DJ name via your 'current playing song' input via your stream server.

Running the script myself, all I get is "feed not loading", this is due to you having a SHOUTcast V1 server, whereas the '/stats?sid=X' parameter is exclusive to SHOUTcast V2.

 

I would not be a fan of this script mainly due to the fact it uses the 'current playing song' output for a different purpose than intended. If you wanted to display what DJ is on air now, along with the current playing song, you would not be able to do so.

 

Since you are on SHOUTcast V1, you will need a script that analyses the '/7.html' script. This uses a comma separated string rather than XML to pull the info.

Studiio - All-In-One Radio Communication Platform
SMS | Phone Calls | Social Media | Content

Link to comment
Share on other sites

I would not be a fan of this script mainly due to the fact it uses the 'current playing song' output for a different purpose than intended. If you wanted to display what DJ is on air now, along with the current playing song, you would not be able to do so.

 

Not exactly true James. That script assumes the song titles have been prepended or appended with the DJ names. Echoing out $parts[1] (assuming appended DJ name) will display the DJ name and echoing out $parts[0] will display the current playing song.

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...
  • 2 years later...

sorry if old post but this script

 

// Use SERVERGENRE instead of SONGTITLE to parse DJ name from the Genre.// $genre = $xml->SERVERGENRE;// echo $genre;
// Next we pull the SONGTITLE from the xml and split the variable with delimiter ":"
$songTitle = $xml->SONGTITLE;$parts = explode(':', $songTitle);
// $parts should now contain 2 strings of text in an array if a DJ is onair, and just one if not.// Use $parts[0] for prepended song titles and $parts[1] for appended song titles.// For prepended (DJ name before title info), DJs must prepend in the format of "DJname: " (without "s.)// For appended (DJ name after title info), DJs must append in the format of ":DJname" (without "s.)// The colon is important as it is what tells us where the DJ name ends and the Song Title begins.
// Next we check if anything is in the second part of our array.if($parts[1] == ""){ 
// If there is nothing in the second part of the array, we know that the Auto DJ is on.echo "AutoDJ OnAir!";
// Instead of just saying AutoDJ OnAir, we can echo out an image based on one located in // a folder called djimages like this// echo "djimages/jukebox.pngAuto DJ";
} else {
// If $parts[1] does have text, our DJ is on.echo $parts[0]." OnAir";
// Instead of just saying DJ XYZ OnAir, we can echo out an image based on one located in// a folder called djimages where the image filename is the same as the djname used like this:// echo "djimages/jukebox.png".$parts[0].".jpgAuto DJ";}?>Reply With QuoteReply With Quote11-05-2017, 10:10 PM

 

can it be of any use for icecast2

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...