PDA

View Full Version : Code I need a Script to show the Current DJ on air (Details Below)



mrdata71
07-19-2017, 10:09 PM
Hello there:

I just switched to a Centova cast V3 Streaming server for Shoutcast V1 and V2.

I lost my ability to have a remote PHP script to show whether the current DJ is Auto DJ or the DJ that is streaming.( I had one through Makeavoice)

Here is the code they used:

<iframe src=http://makeavoice.com/shoutcast/websitecodes/autodjstatus.php?ip=173.236.59.82&port=8000&refresh=10&fontcolor=white&onlinefontcolor=green width=200 height=60 frameborder=0 scrolling=no></iframe>

If someone can help me with making one that would be most helpful.

Thank you in advance!

James
07-20-2017, 06:48 AM
Looks like that script still works? Or is that just a sample stream?

What does it look like when the DJ is streaming? To me, this could prove difficult as SHOUTcast does not output anything natively to tell whether its Auto DJ or someone DJing. The AutoDJ software is separate from SHOUTcast, so you would need to find out what Makeavoice use (Centova? WHM?), and use their API's to determine.

PapaBearPW
07-20-2017, 09:31 AM
Yep. Works for me too. Just one thing...the space between the s and h in refresh=10. Had to remove that space, then it seems fine. But that may have just been a typo when posting it here.

shoutcaststreaming
07-20-2017, 06:03 PM
I think he implied that it already worked. What he asked for is a new script for his new Stream Host.

mrdata71
07-21-2017, 01:24 AM
yes I need a new script for centova cast. Makeavoice uses Shoutcast 1.9.8 and Shoutca.st uses Shoutcast 2.4.7 I believe. It is Centova Cast V3 for an interface. If someone has a script that I can use and insert my server info, that would be great.

PapaBearPW
07-21-2017, 09:45 PM
In that case, there are a couple of possibilities. First one depends on knowing what Centova Cast uses for AutoDJ and if it has an api you can access to pull the needed info. So, you would need to ask them about that. The other way is to "hijack" one of the Shoutcast v2 stats and parse the xml data. That one would require your DJs to either be able to either prepend or apend the song title updates (some software provides a means to do this, including LCDJ and SAM Broadcaster) with their DJ names or use the Genre setting for this purpose. It is also possible to pull from Shoutcast v1.x but, only via the title updates means.

I can help you out with some code for all that, but I would need to know what Shoutcast version?

mrdata71
07-22-2017, 03:11 AM
Believe it or not, I am using SAM 4.2.2

And what is funny is that this website also helped me make the Statistic Relays able to work.

I had to rig the setup for that but it works like a champ.

Thanks for helping.

PapaBearPW
07-22-2017, 09:08 AM
So, are you saying you need the script or not anymore? I'm a little confused.

mrdata71
07-22-2017, 12:47 PM
I do need the script because i cannot get it to show on the website. i never used SAM to put the DJ name on the website. I never said i did not need it anymore.

mrdata71
07-22-2017, 12:48 PM
the Statistic Relays and the DJ name on the website for who is On Air are 2 different things.

PapaBearPW
07-22-2017, 01:47 PM
Give this a try and let me know how it works for you. The code itself is just a couple lines, but I thought it best to put in a good amount of comments to explain what is going on.



<?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://host:port/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 "<img src='djimages/AutoDJ.jpg'>Auto DJ</img>";

} 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 "<img src='djimages/".$parts[0].".jpg'>Auto DJ</img>";
}
?>

djaubs89
07-22-2017, 04:06 PM
that code don't work for me

PapaBearPW
07-22-2017, 04:35 PM
Did you try it after the edit I made? There was a mistake in it that I fixed about 12 minutes before you posted. I was able to get your server info from my side. So, it should work for you too.

mrdata71
07-22-2017, 08:47 PM
I am getting an error in the code when I put it into an HTMl box on my website:

SERVERGENRE; // echo $genre; // Next we pull the SONGTITLE from the xml and split the variable with delimiter ":" $songTitle = $xml->SONGTITLE; $parts = explode(':'

shoutcaststreaming
07-22-2017, 08:54 PM
I tried the code and it works for me.

mrdata71
07-22-2017, 09:03 PM
Can you give some insight as to how you are adding this to your website? I cannot upload files to my website and have to add it in an HTML box. Yes I am still learning this and need some assistance please. I so want this code to work. I have a DJ on air right now.

PapaBearPW
07-22-2017, 09:08 PM
That is a php script. If you need to put it inside a pure html page (or box), you should probably upload the code as a php file to your server and then include the php file inside your html box by using an iframe.

mrdata71
07-23-2017, 03:17 AM
That is a php script. If you need to put it inside a pure html page (or box), you should probably upload the code as a php file to your server and then include the php file inside your html box by using an iframe.

I tried to make a folder and it told me 'Wrong File Type' when i uploaded it.

PapaBearPW
07-23-2017, 10:06 AM
More details would be helpful in trying to determine what the problem is.

You tried to make a folder where?
Using what?
Wrong File Type reported by what?
For what filename exactly?

mrdata71
07-23-2017, 04:22 PM
i was trying to upload it to my Centova Cast where i send my songs so i made a new folder called PHP. I was able to upload it as an MP3 and reame it as .php but i cant access the file with iframe code.

James
07-24-2017, 01:09 AM
i was trying to upload it to my Centova Cast where i send my songs so i made a new folder called PHP. I was able to upload it as an MP3 and reame it as .php but i cant access the file with iframe code.

You need to upload to your webserver, not Centova Cast. Centova Cast is for music files, your website is for hosting.. your website. Looks like you host your website through GoDaddy, either use FTP/SFTP or their web interface to upload the script.

mrdata71
07-24-2017, 02:11 AM
OK I cannot FTP or they won tell me how to do so. Has anyone ever FTP'ed to a Godaddy site?

mrdata71
07-24-2017, 02:22 AM
I also found out that the website is not hosted so i cannot upload php file to it.

shoutcaststreaming
07-24-2017, 03:39 AM
If you don't have to upload & load a PHP file, then it won't work for you.

James
07-24-2017, 04:36 AM
OK I cannot FTP or they won tell me how to do so. Has anyone ever FTP'ed to a Godaddy site?

https://godaddy.com/help/ftp-how-to-upload-files-96

You can FTP using the guide in their support portal above. Unless you use GoDaddy's website builder, in that case you won't be able to upload this PHP script as SCS has mentioned above.

mrdata71
07-24-2017, 01:26 PM
I use the website builder. So is there any other alternatives to making this work?

James
07-24-2017, 11:47 PM
I use the website builder. So is there any other alternatives to making this work?

Not that I can think of right now. I am currently building a paid service that forms a part of this but that is not ready yet.

PapaBearPW
07-27-2017, 10:33 AM
There might be a way using javascript to do something. But my javascript mojo is pretty weak so, I won't be much help with that. A service like James is talking about might be a better option for you.

mrdata71
07-30-2017, 03:01 PM
Not that I can think of right now. I am currently building a paid service that forms a part of this but that is not ready yet.

Please let me know when this is ready. Even if I had a button on my website that would show the current DJ that is better than nothing.

mrdata71
08-21-2017, 09:57 PM
I now have FTP access. Let me see what I can do.

djaubs89
08-29-2017, 09:27 PM
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 "<img src='http://urban-radio.co.uk/images/jukebox.gif'>Auto DJ</img>";


} 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 "<img src='djimages/".$parts[0].".jpg'>Auto DJ</img>";
}
?>

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

mrdata71
08-29-2017, 10:40 PM
ok so how do I use this php file to display it on my website? Yes i am still new to this and am in the process of rebuilding it using cpanel.

Thanks in advance!

James
08-30-2017, 05:48 AM
I have a simplified PHP script in this post:
http://forums.broadcastingworld.com/showthread.php/15461-on-air-script?p=96159&#post96159

mrdata71
08-30-2017, 06:31 PM
Awesome! I will let you know when i am able to test it and let you know the results.

ultra89
11-05-2017, 03:12 PM
can someone show me an example page of this php code working please
i have edited this code before posting



<?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://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 "<img src='djimages/jukebox.png'>Auto DJ</img>";

} 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 "<img src='djimages/jukebox.png".$parts[0].".jpg'>Auto DJ</img>";
}
?>

James
11-05-2017, 09:10 PM
can someone show me an example page of this php code working please
i have edited this code before posting



<?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://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 "<img src='djimages/jukebox.png'>Auto DJ</img>";

} 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 "<img src='djimages/jukebox.png".$parts[0].".jpg'>Auto DJ</img>";
}
?>


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.

PapaBearPW
11-06-2017, 04:51 PM
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.

airmedia
03-13-2018, 10:40 PM
I think what would be a good feature is for someone to screen shot the way to do it and put it on youtube.
this could help out a lot of people.

ultra89
03-27-2018, 08:37 PM
mrdata i have looked on you're website and you have a box that says requests offline?

is there anyway i could a code that says that