Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Shoutcast v2 help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Proximity" data-source="post: 382441" data-attributes="member: 43026"><p>Hey Devbesters,</p><p></p><p>I need help converting this piece of code to work with shoutcast v2. It works for v1 but I need it for v2.</p><p></p><p>[code=Shoutcast code]</p><p> public function radioInfo( $url ) {</p><p> </p><p> $opts = array(</p><p> </p><p> 'http' => array(</p><p> </p><p> 'method' => 'GET',</p><p> 'header' => 'User-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n'</p><p> </p><p> )</p><p> </p><p> );</p><p></p><p> $context = stream_context_create( $opts );</p><p></p><p> $data = @file_get_contents( $url, false, $context );</p><p></p><p> if( preg_match( "/Stream is currently up and private (not listed)/", $data ) ) {</p><p> </p><p> $return['online'] = true;</p><p></p><p> $return['listeners'] = explode("kbps with <B>", $data);</p><p> $return['listeners'] = explode(" of", $return['listeners'][1]);</p><p> $return['listeners'] = $return['listeners'][0];</p><p></p><p> $return['ulisteners'] = explode("listeners (", $data);</p><p> $return['ulisteners'] = explode(" unique", $return['ulisteners'][1]);</p><p> $return['ulisteners'] = $return['ulisteners'][0];</p><p></p><p> $return['listenerpeak'] = explode("Listener Peak: </font></td><td><font class=default><b>", $data);</p><p> $return['listenerpeak'] = explode("</b>", $return['listenerpeak'][1]);</p><p> $return['listenerpeak'] = $return['listenerpeak'][0];</p><p></p><p> $return['streamtitle'] = explode("Stream Title: </font></td><td><font class=default><b>", $data);</p><p> $return['streamtitle'] = explode("</b>", $return['streamtitle'][1]);</p><p> $return['streamtitle'] = $return['servertitle'][0];</p><p></p><p> $return['genre'] = explode("Stream Genre: </font></td><td><font class=default><b>", $data);</p><p> $return['genre'] = explode("</b>", $return['SERVERGENRE'][1]);</p><p> $return['genre'] = $return['SERVERGENRE'][0];</p><p></p><p> $return['currentsong'] = explode("Current Song: </font></td><td><font class=default><b>", $data);</p><p> $return['currentsong'] = explode("</b>", $return['currentsong'][1]);</p><p> $return['currentsong'] = $return['songtitle'][0];</p><p> </p><p> }</p><p> else {</p><p> </p><p> $return['online'] = false;</p><p> </p><p> }</p><p></p><p> return $return;</p><p> }</p><p>[/code]</p></blockquote><p></p>
[QUOTE="Proximity, post: 382441, member: 43026"] Hey Devbesters, I need help converting this piece of code to work with shoutcast v2. It works for v1 but I need it for v2. [code=Shoutcast code] public function radioInfo( $url ) { $opts = array( 'http' => array( 'method' => 'GET', 'header' => 'User-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n' ) ); $context = stream_context_create( $opts ); $data = @file_get_contents( $url, false, $context ); if( preg_match( "/Stream is currently up and private (not listed)/", $data ) ) { $return['online'] = true; $return['listeners'] = explode("kbps with <B>", $data); $return['listeners'] = explode(" of", $return['listeners'][1]); $return['listeners'] = $return['listeners'][0]; $return['ulisteners'] = explode("listeners (", $data); $return['ulisteners'] = explode(" unique", $return['ulisteners'][1]); $return['ulisteners'] = $return['ulisteners'][0]; $return['listenerpeak'] = explode("Listener Peak: </font></td><td><font class=default><b>", $data); $return['listenerpeak'] = explode("</b>", $return['listenerpeak'][1]); $return['listenerpeak'] = $return['listenerpeak'][0]; $return['streamtitle'] = explode("Stream Title: </font></td><td><font class=default><b>", $data); $return['streamtitle'] = explode("</b>", $return['streamtitle'][1]); $return['streamtitle'] = $return['servertitle'][0]; $return['genre'] = explode("Stream Genre: </font></td><td><font class=default><b>", $data); $return['genre'] = explode("</b>", $return['SERVERGENRE'][1]); $return['genre'] = $return['SERVERGENRE'][0]; $return['currentsong'] = explode("Current Song: </font></td><td><font class=default><b>", $data); $return['currentsong'] = explode("</b>", $return['currentsong'][1]); $return['currentsong'] = $return['songtitle'][0]; } else { $return['online'] = false; } return $return; } [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Shoutcast v2 help
Top