Shoutcast v2 help

Proximity

IDK?
Feb 13, 2014
673
56
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:
        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;
        }
 

Ollie

Member
Jan 7, 2013
72
11
Well to start off, you don't want to convert that code at all, as v2 has its own api, where it does the work for you. So start by looking at that.
 

Proximity

IDK?
Feb 13, 2014
673
56
I need to update that script

Code:
    $query  = $db->query( "SELECT * FROM connection_info ORDER BY id DESC LIMIT 1" );
    $array  = $db->assoc( $query );

    $info   = $core->radioInfo( "http://{$array['host']}:{$array['port']}" );
if ($info['error'] == "Disabled."){

It uses it in another page
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
I need to update that script

Code:
    $query  = $db->query( "SELECT * FROM connection_info ORDER BY id DESC LIMIT 1" );
    $array  = $db->assoc( $query );

    $info   = $core->radioInfo( "http://{$array['host']}:{$array['port']}" );
if ($info['error'] == "Disabled."){

It uses it in another page
You don't need to update that script. You can just use the same function name and return an array with the same keys.

However, I assume you aren't looking for help (as we just gave you enough directions to start figuring it out yourself) based on your previous threads, so if you want someone to do it for you, post a request. Not an help thread.
 

Users who are viewing this thread

Top