Old 7th January 2017, 05:09   #1
jcnyct
Junior Member
 
Join Date: Dec 2016
Location: New York, NY
Posts: 42
Embed Shoutcast V2 Stats

Hey there,

Does anyone have a PHP script that displays "Current Listeners" as a sum of multiple shoutcast v2 streams/mountpoints?

I tried this code but keep getting 0 as a result: https://www.dlnetworks.net/scratch/multi-shout-totals/

I've tried others mentioned in this forum with no success

Perhaps different coding is required for SHOUTcast Server v2.5.1.723??

thanks in advance for any help
jcnyct is offline   Reply With Quote
Old 7th January 2017, 11:18   #2
neralex
Senior Member
 
Join Date: Mar 2011
Posts: 435
You can do it with XML or with JSON. Please check the DNAS docs in the download-folder:

/docs/DNAS_Server_XML_Responses.html
/docs/DNAS_Server_JSON_Responses.html

http://forums.winamp.com/showthread....03#post3015503

PHP Code:
<?php
$sc_count 
0;
$sc_ip '123.135.8.79';
$sc_port '8000';

$sc_sid 1;
$xml = @simplexml_load_file('http://' $sc_ip ':' $sc_port '/stats?sid=' $sc_sid);
if (
$xml === FALSE) {
    
$count_current_1 '0';
    
$status_1 '0';
    
$current_title_1 'no title available';
} else {
    
$count_current_1 $xml->CURRENTLISTENERS# current listeners
    
$status_1 $xml->STREAMSTATUS# stream status
    
$current_title_1 $xml->SONGTITLE# stream-title
}

echo 
'Listeners (sid= ' $sc_sid '): ' $count_current_1 '<br />';
echo 
'Stream-Status (sid=' $sc_sid '): ' $status_1 '<br />';
echo 
'Current Streanttitle (sid=' $sc_sid '): ' $current_title_1 '<br />';

$sc_sid 2;
$xml = @simplexml_load_file('http://' $sc_ip ':' $sc_port '/stats?sid=' $sc_sid);
if (
$xml === FALSE) {
    
$count_current_2 '0';
    
$status_2 '0';
    
$current_title_2 'no title available';
} else {
    
$count_current_2 $xml->CURRENTLISTENERS# current listeners
    
$status_2 $xml->STREAMSTATUS# stream status
    
$current_title_2 $xml->SONGTITLE# stream-title
}

echo 
'Listeners (sid=' $sc_sid '): ' $count_current_2 '<br />';
echo 
'Stream-Status (sid=' $sc_sid '): ' $status_2 '<br />';
echo 
'Current Streanttitle (sid=' $sc_sid '): ' $current_title_2 '<br />';

$sc_count $count_current_1 $count_current_2;
echo 
'Listeners (sum): ' $sc_count '<br />';

?>
neralex is offline   Reply With Quote
Old 8th January 2017, 15:35   #3
jcnyct
Junior Member
 
Join Date: Dec 2016
Location: New York, NY
Posts: 42
Quote:
Originally Posted by neralex View Post
You can do it with XML or with JSON. Please check the DNAS docs in the download-folder:

/docs/DNAS_Server_XML_Responses.html
/docs/DNAS_Server_JSON_Responses.html

http://forums.winamp.com/showthread....03#post3015503

PHP Code:
<?php
$sc_count 
0;
$sc_ip '123.135.8.79';
$sc_port '8000';

$sc_sid 1;
$xml = @simplexml_load_file('http://' $sc_ip ':' $sc_port '/stats?sid=' $sc_sid);
if (
$xml === FALSE) {
    
$count_current_1 '0';
    
$status_1 '0';
    
$current_title_1 'no title available';
} else {
    
$count_current_1 $xml->CURRENTLISTENERS# current listeners
    
$status_1 $xml->STREAMSTATUS# stream status
    
$current_title_1 $xml->SONGTITLE# stream-title
}

echo 
'Listeners (sid= ' $sc_sid '): ' $count_current_1 '<br />';
echo 
'Stream-Status (sid=' $sc_sid '): ' $status_1 '<br />';
echo 
'Current Streanttitle (sid=' $sc_sid '): ' $current_title_1 '<br />';

$sc_sid 2;
$xml = @simplexml_load_file('http://' $sc_ip ':' $sc_port '/stats?sid=' $sc_sid);
if (
$xml === FALSE) {
    
$count_current_2 '0';
    
$status_2 '0';
    
$current_title_2 'no title available';
} else {
    
$count_current_2 $xml->CURRENTLISTENERS# current listeners
    
$status_2 $xml->STREAMSTATUS# stream status
    
$current_title_2 $xml->SONGTITLE# stream-title
}

echo 
'Listeners (sid=' $sc_sid '): ' $count_current_2 '<br />';
echo 
'Stream-Status (sid=' $sc_sid '): ' $status_2 '<br />';
echo 
'Current Streanttitle (sid=' $sc_sid '): ' $current_title_2 '<br />';

$sc_count $count_current_1 $count_current_2;
echo 
'Listeners (sum): ' $sc_count '<br />';

?>

Thanks for your help.. unfortunately I get a blank page - I configured with our IP & Port
jcnyct is offline   Reply With Quote
Old 8th January 2017, 16:22   #4
neralex
Senior Member
 
Join Date: Mar 2011
Posts: 435
Works without a hit. Not sure where you let it run but make sure the server runs with a webserver like apache2 or nginx and php5 or php7 and the file is inside a web-directory.
neralex is offline   Reply With Quote
Old 9th January 2017, 03:39   #5
jcnyct
Junior Member
 
Join Date: Dec 2016
Location: New York, NY
Posts: 42
yeah apache 2, php 5 and inside web directory.. blank page

have you tested with SHOUTcast v2.5.1.723 ??
jcnyct is offline   Reply With Quote
Old 9th January 2017, 04:35   #6
neralex
Senior Member
 
Join Date: Mar 2011
Posts: 435
Yes for sure, but a blank page has nothing do to with SHOUTcast!

Compare what you pasted. You have to paste all codelines inclusive <?php ... ?> ! If you made changes, compare it also with the original code. Check your php error-log to find the issues. The script is clean and runs without any error.
neralex is offline   Reply With Quote
Old 9th January 2017, 15:13   #7
jcnyct
Junior Member
 
Join Date: Dec 2016
Location: New York, NY
Posts: 42
cool.. thanks for your help. It's all pasted correctly, with IP and port as only change.. I'll email my web hosting support.. it looks like our site might have some type of php script block

thanks again,
jcnyct is offline   Reply With Quote
Old 9th January 2017, 15:26   #8
djSpinnerCee
Forum King
 
djSpinnerCee's Avatar
 
Join Date: Aug 2004
Location: Hollis, Queens/The Bronx, NYC
Posts: 3,358
Send a message via ICQ to djSpinnerCee Send a message via AIM to djSpinnerCee
most php hosting does not allow hosted scripts to make external http (tcp) requests.
djSpinnerCee is offline   Reply With Quote
Old 10th January 2017, 14:30   #9
jcnyct
Junior Member
 
Join Date: Dec 2016
Location: New York, NY
Posts: 42
thanks for the help guys.. sent quick email to web hosting provider and issue solved
jcnyct is offline   Reply With Quote
Old 28th February 2017, 15:55   #10
TopFloorDjs
Junior Member
 
Join Date: Feb 2011
Posts: 9
HTML Code:
Listeners (sid= 1): 0
Stream-Status (sid=1): 0
Current Streanttitle (sid=1): no title available
Listeners (sid=2): 0
Stream-Status (sid=2): 0
Current Streanttitle (sid=2): no title available
Listeners (sum): 0
http://192.241.129.98:9300/index.html?sid=1
TopFloorDjs is offline   Reply With Quote
Old 28th February 2017, 20:33   #11
neralex
Senior Member
 
Join Date: Mar 2011
Posts: 435
@TopFloorDjs you have to add your IP and port at the top of the script.

$sc_ip = '192.241.129.98';
$sc_port = '9300';

HTML Code:
Listeners (sid= 1): 0
Stream-Status (sid=1): 1
Current Streanttitle (sid=1): TWRK & Lambo - The Benzi Edit Vault (LDS #192) - Independent (VIP SHORT EDIT)
BTW: If you don't need the part for sid=2, then you can delete all between:

PHP Code:
echo 'Current Streanttitle (sid=' $sc_sid '): ' $current_title_1 '<br />'
and...

PHP Code:
?> 
neralex is offline   Reply With Quote
Old 28th February 2017, 22:39   #12
TopFloorDjs
Junior Member
 
Join Date: Feb 2011
Posts: 9
Thanks, for some careless reason i kept the http:// in before the hostip. How can i view the XML file so i can grab more data from it?

Firstly im hoping to grab all strings so i can show stats like (if autodj === enabled)

Once ive grabbed all the data im going to google how to take data from the PHP file and use it in my vBulletin4 template.
TopFloorDjs is offline   Reply With Quote
Old 1st March 2017, 04:50   #13
neralex
Senior Member
 
Join Date: Mar 2011
Posts: 435
/docs/DNAS_Server_XML_Responses.html

http://192.241.129.98:9300/stats?sid=1

http://php.net/manual/en/function.include-once.php
neralex is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > SHOUTcast > SHOUTcast Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump