![]() |
#1 |
Junior Member
Join Date: Feb 2011
Posts: 2
|
php code for shoutcast status
the previous version of shoutcast was easy .. anything I needed to display on my website was contained in 7.html
none of the old scripts now work with shoutcast2 After a fruitless search of the interwebs for a script or tutorial maybe you guys could help. Can anyone direct me to a code snippet that will show Peak Listeners, current listeners, now playing and last 9 songs for the new shoutcast2. |
![]() |
![]() |
![]() |
#2 |
Major Dude
|
The new server doesnt support 7html. When 7html was discovered, it was more of a hack to supporting metadata, granted is does use MUCH less bandwidth /w massive listener counts than conventional php stat displays. Then again, something could have changed over the last 7 months and I just don't know
![]() |
![]() |
![]() |
![]() |
#3 | |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
Quote:
"If you don't like DNAS, write your own damn system" So I did |
|
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Feb 2011
Posts: 2
|
which brings us back to the original question.
what is the name of the file that I need to extract the data from now that 7.html does not exist? |
![]() |
![]() |
![]() |
#5 |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
index.html
played.html "If you don't like DNAS, write your own damn system" So I did |
![]() |
![]() |
![]() |
#6 |
Join Date: Sep 2003
Posts: 27,873
|
http://dev.winamp.com/wiki/SHOUTcast...stration_Pages lists all of the options for querying things from the v2 DNAS either as public pages or as private pages for specific admin details along with the means to only get certain sets of data instead of a full-blown xml response (which the default output has been reduced since the initial v2 build 7 + 10 was outputting stuff that was never populated).
-daz |
![]() |
![]() |
![]() |
#7 | |
Senior Member
Join Date: Jan 2010
Posts: 181
|
Hi,
if you have access to the admin.cgi of the DNAS you could use this script: PHP Code:
***91; have to be changed to [ ***93; have to be changed to ] This script reads all infos from the xml-file generatet by DNAS and make them available as an array. you can simply include the file in your current php website. If you want to view the current song you can access it by Quote:
Hope that helps ![]() EDIT: the php CURL-Lib must be installed, but thats this lib afaik is standard on php 5 and higher installations. Greeting MAD |
|
![]() |
![]() |
![]() |
#8 | |
Major Dude
Join Date: Mar 2011
Posts: 576
|
hey MADxHAWK!
do you have test it? i have no output with echo. can you fixit, please? examples: PHP Code:
Quote:
|
|
![]() |
![]() |
![]() |
#9 |
Junior Member
Join Date: Mar 2011
Posts: 7
|
Is it possible to change this to use the v1 server too?
Does it work if I change this var? PHP Code:
|
![]() |
![]() |
![]() |
#10 |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
It's not that simple ... you need to change the URL
possibly from PHP Code:
PHP Code:
PHP Code:
"If you don't like DNAS, write your own damn system" So I did |
![]() |
![]() |
![]() |
#11 |
Junior Member
Join Date: Mar 2011
Posts: 7
|
I have made the suggested changes to the script, but I'm getting the could not connect error. I have 3 different streams to test this with and tried them all. None of them are v2. Do I need to include the path to curl on that page?
|
![]() |
![]() |
![]() |
#12 | |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
you've changed these to suit?
Quote:
"If you don't like DNAS, write your own damn system" So I did |
|
![]() |
![]() |
![]() |
#13 |
Junior Member
Join Date: Mar 2011
Posts: 7
|
Well, they have allowed it in the past. I'd say a few years ago. I just sent them a ticket, so I should know in the morning, hopefully. Do you think they would re-enable this if i asked them? I've been with the same host since 2002. Doubt that makes a difference.
@jaromanda - Yes, I did make the necessary changes to those variables too, but the truth is I've been looking for a flash player and a script like this that works on my server for days. |
![]() |
![]() |
![]() |
#14 |
Senior Member
Join Date: Jan 2010
Posts: 181
|
Hi,
sorry have missed this post :S This script uses the phpCURL libary to connect to the shoutcast server. If you dont get any data maybe this lib is not installed on your server/webspace. Also most free webspacehoster dont allow external connections (like funpic for example). Look for the line: code: after add: code: This line will dump the data curl gets. You can use this script with a shoutcast 1 also. you just have to change the line like jaromanda sugested. But you wont get all data from shoutcast 1. For example shoutcast 1 provided also webhits, admin logins and a few more data that shoutcast 2 doesnt. To get an output you need this line for example: (sorry there was a typo in the example) echo $dnas_data ['SONGTITLE']; This line wont give you any output: echo $xml->SONGTITLE; A simple html file to get the current song and songhistory could look something like this: current_song.php code: The file have to be named *.php NOT *.htm or *.html !! else the phpcode wont be parsed. Maybe i will write a shoutcast class working where you can select weather to use curl or fsockopen for connection to shoutcast working with both versions of the DNAS. |
![]() |
![]() |
![]() |
#15 |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
why not also a straight file_get_contents with a context that sets a appropriate useragent ... works for my host
"If you don't like DNAS, write your own damn system" So I did |
![]() |
![]() |
![]() |
#16 |
Senior Member
Join Date: Jan 2010
Posts: 181
|
The script is for radio stations not for Listeners (you need admin access to the DNAS)
The most common problem is, most webspace Hoster still have php_save_mode restrictions active and these restrictions will block all external fileaccess. I have used phpcurl, cause it a simple and easy way to get the data i need. Even mor simple than using fsockopen or file_get_contend. With fsockopen and file_get_contend you have to open the connection with http://login:password@streamurl:port and i dont like that way to transmit the logindata ;) and thats another reason, why i desided to use php-curl. |
![]() |
![]() |
![]() |
#17 |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
ok, good explanation
"If you don't like DNAS, write your own damn system" So I did |
![]() |
![]() |
![]() |
#18 |
Junior Member
Join Date: Mar 2011
Posts: 7
|
Well the host has never been a free one that I'm using, but as I said in the earlier post, they have allowed outgoing connections in the past. They definitely have curl installed. I know I'm the admin of these stations because I made them. I can safely consider myself at least above a novice in php since I built my stations site in nothing but php & mysql. Here is my code for the array output:
code: I'm still waiting on a reply from the host to verify if they allow it or not, but based on the scripts I've tried, my opinion is that they don't. |
![]() |
![]() |
![]() |
#19 | |
Major Dude
Join Date: Mar 2011
Posts: 576
|
Quote:
thanks for your reply but the script is not working. i become a redirect to the index.html. can you test your script before you post it, please. my questions: why is the curl not close and/or where is the right place for this line? code: why is'nt in your script a call to the port? code: why give the the sc_serv2 a redirect? i have try in my putty: code: greets |
|
![]() |
![]() |
![]() |
#20 |
Junior Member
Join Date: Mar 2011
Posts: 7
|
So I got sick of waiting for a response for the ticket I sent in and gave my host a call and they pretty much told me that I needed to change my shoutcast servers to port 80, which is apparently the only way to get past their firewall. So how is that supposed to work when two of my servers are free servers and I have no access to their configs?
Edit: making a similar reply to the ticket I sent. |
![]() |
![]() |
![]() |
#21 | ||
Senior Member
Join Date: Jan 2010
Posts: 181
|
Hi pimphesus,
well the script works fine, im using it on my own station. But you are right, i realy forgot the line PHP Code:
PHP Code:
Quote:
PHP Code:
Quote:
1. you have to decide running a webserver or a shoutcast, both doesnt work cause webserver also run on port 80. 2. if the realy only allow port 80 you shoutcast wont run ayway cause you need 2 ports for shoutcast, portbase and portbase +1, so you would need port 80 and 81 -MAD |
||
![]() |
![]() |
![]() |
#22 | |
Forum King
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,290
|
Quote:
b) also, just because the webhost has port restrictions don't mean the shoutcast host has restrictions c) MOST cheap/free webhosts do not allow outgoing requests on "exotic" ports ... i.e. they will allow http(80), probably https(443), maybe ftp and maybe a few others "If you don't like DNAS, write your own damn system" So I did |
|
![]() |
![]() |
![]() |
#23 |
Senior Member
Join Date: Jan 2010
Posts: 181
|
ok thought it was the server with the restrictions shoutcast is running on, sorry.
anyway i pay less than 3us$/month for my privat webspace and dont have such restrictions try to start shoutcast on port 80 when a webserver is running, i bet shoutcast wouldnt start. shoutcast using port 80 for incoming and outgoing connects and the webserve to, it wont work ![]() -MAD |
![]() |
![]() |
![]() |
#24 |
Junior Member
Join Date: May 2011
Posts: 1
|
Nice script!
But I encountered a problem. This didn't work for me: PHP Code:
PHP Code:
![]() |
![]() |
![]() |
![]() |
#25 |
Forum King
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
|
just an FYI all this is clear text so the username and password can be intercepted to your shoutcast admin interface. why not read 7.html or last.html neigher require you to use the username and password at all.
I have a now playing that inside a wordpress page template and it shows the now playing and even puts in a link to amazon to purchase that track if its on amazon. Less than 40 lines of php code and it doesn't send the admin username or password. as its not needed to read the now playing. Also less overhead on the shoutcast server as well. ~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough. ![]() search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn. |
![]() |
![]() |
![]() |
#26 |
Senior Member
Join Date: Oct 2011
Posts: 105
|
i got
string(112) "Click HERE for redirect." when i tried to echo $dnas_data['SONGTITLE']; what could be the problem? |
![]() |
![]() |
![]() |
#27 |
Senior Member
Join Date: Oct 2011
Posts: 105
|
it now works by changing URL to
$ch = curl_init($sc_host . '/admin.cgi?sid=' . $sc_sid . '&mode=viewxml'); anyway, how can i make the song update in real time? i dont know ajax |
![]() |
![]() |
![]() |
#28 |
Junior Member
Join Date: Jan 2012
Posts: 31
|
Hi guys...
I have taylored a php munin plugin using your code. It is also based on the stable shoutcast 198 munin plugin public at the repository. It works great: now we have v2 graphs!!! Since it uses most of your essential code, I wonder wether I could make it available at the munin repository so it can be useable. Thanks, regards |
![]() |
![]() |
![]() |
#29 |
Junior Member
Join Date: Jan 2012
Posts: 31
|
Also note:
the 32 bit binary uses UNIQUELISTENERS as XML tag whereas the 64 bit binary uses REPORTEDLISTENERS as XML tag take this into account when working on it! |
![]() |
![]() |
![]() |
#30 |
Join Date: Sep 2003
Posts: 27,873
|
are you sure you're using the same and current build as REPORTEDLISTENERS was removed in the RC builds and also there is no platform specific differences on the stats reporting as it would server no purpose and would completely defeat the whole point of the v2 DNAS acting the same on any platform it is run on.
http://wiki.winamp.com/wiki/SHOUTcas...2_XML_Reponses is pretty clear on what values are provided. i'd suggest re-reading and making sure you're DNAS builds are current. -daz |
![]() |
![]() |
![]() |
#31 |
Junior Member
Join Date: Jan 2012
Posts: 31
|
well.... I actually simply downloaded the binaries, i didnt build/compile anything, get them from winamp, paste, and let them run flawlesly... maybe I'm doing wrong.
and, about the difference, I simply noted that, using my brand new new plugin on different (production, lab was done in a 64 bit machine) 32bit machines, I missed unique listeners field information... At first I was confused, since I simply copy/paste it, but, as I directly put the url on my browser against the conflicting servers, I could see the difference when comparing with the 64 bit binary... In the browser window opened at the testbed system 64bit I saw a flag (is the fourth if I remember) REPORTEDLISTENERS whereas in the 32bit server it appeared in the same position as UNIQUELISTENERS As a side note... my plugin is not working with munin in the 32 bit machines, although it runs perfect by munin-node it doesnt feed graphs to the munin server... all this work rock stable in the 64 bit machines, but I guess its just coincident, and strictly munin stuff related, and I have to let munin people discuss about it |
![]() |
![]() |
![]() |
#32 |
Join Date: Sep 2003
Posts: 27,873
|
i will repeat myself, REPORTEDLISTENERS is not a field which is returned by _any_ of the current builds and you really need to confirm what version of the DNAS builds you are using.
-daz |
![]() |
![]() |
![]() |
#33 | |
Junior Member
Join Date: Aug 2012
Posts: 1
|
Reply
Quote:
Hello Mad, Your code works great except for the fact that when I load the page all of the XML data shows up right away. This is obviously an issue seeing as I can't do a custom way. If you have any way of fixing this please let me know. Regards, Adam EDIT: It also keeps screwing with the <title> of the website. |
|
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|