Announcement

Collapse
No announcement yet.

Shoutcast v2 Song History

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shoutcast v2 Song History

    Hello Everybody,

    Since i step over to shoutcast v2 my song history script does not work anymore.
    Is there a good working one ? I searched a few days on google but i can only find old ones that dont work.

    Thanks

  • #2
    This is the Script I'm using.

    code:

    <?php
    error_reporting(0);

    $scip = "xxx.xx.xxx.xx"; // Server IP
    $scport = "POORT"; // Port
    $scpass = "**********"; // Password
    $scversion = "2"; // Shoutcast Version
    $scID = "1"; // Server ID
    $imgKey = "MYAPI"; // LastFM api to Get Images

    $scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
    if(!$scfp) {
    $scsuccs=1;
    echo'Offline';
    }
    if($scsuccs!=1){

    fputs ($scfp, "GET /admin.cgi?sid=$scID&pass=$scpass&mode=viewxml&page=4 HTTP/1.1\r\nHost: $scip:$scport\r\n .
    User-Agent: User (Mozilla Compatible)\r\n .
    Authorization: Basic ".base64_encode ("admin:$scpass")."\r\n\r\n");
    while(!feof($scfp)) {
    $page .= fgets($scfp, 1000);
    }

    $loop = array("STREAMSTATUS", "BITRATE");
    $y=0;
    while($loop[$y]!=''){
    $pageed = ereg_replace(".*<$loop[$y]>", "", $page);
    $scphp = strtolower($loop[$y]);
    $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
    if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE)
    $$scphp = urldecode($$scphp);

    $y++;
    }

    $pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
    $pageed = ereg_replace("</SONGHISTORY>.*", "", $pageed);
    $songatime = explode("<SONG>", $pageed);
    $a = 0;
    $r=1;
    while($songatime[$r]!=""){
    $t=$r-1;
    $playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
    $playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
    $song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
    $song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
    $song[$t] = urldecode($song[$t]);
    list ($artiest, $titel) = explode(" - ", $song[$t]);
    $rij_kleur = ($a++ % 2) ? "#f5f5f5" : "#e8e8e8";

    $xml = simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=$artiest&api_key=$imgKey");
    $trackimg = $xml->artist->image[2];

    if ($trackimg == "") {
    $trackimg = "../noIMG.png";
    }

    if ($artiest == "LIVE" AND $titel == "-=ON AIR=-") {
    $trackimg = "../live.jpg";
    }

    echo'<div style="background-color: '.$rij_kleur.';>
    <p style="width: 65px;"><img style="margin-top:5px; margin-left:5px; border-radius: 100%; border: 1px solid #ff1190; width: 60px; height: 60px;" src="'.$trackimg.'" /></p>
    <div style="display:block; margin: -66px 0px 0px 80px; float:left;">
    <i class="fa fa-microphone"></i> <strong>'.$artiest.'</strong><br />
    '.$titel.'</a>
    </div></div>';

    $r++; }
    fclose($scfp);
    }
    ?>

    It always worked before.
    I'm even getting a HTTP ERROR 500

    Comment


    • #3
      i'll check it out 4 ya.... stand by....
      /* v2 HTML5 / Player test pages DigitalMixNYC, DigitalMixNYCbx | DNAS Status: Now Playing js codes (scaststatus_X.php) | PortForward.com | Upload/Download Speed Test | No-IP.com: Free Dynamic DNS | In the YP | dnasDir */

      Comment


      • #4
        sc_played_v2.php - v2 dnas history

        ok- simple fix. basically the admin.cgi url needed tweaking.
        PHP Code:
        <?php

        error_reporting
        (0);

        $scip           "127.0.0.1";   // Server IP/hostname

        $scport         "8000";   // Port

        $scpass         "changeme";   // Password

        $scversion      "2";   // Shoutcast Version

        $scID           "1";   // Server ID [sid=]

        $imgKey         "MYAPI";   // LastFM api to Get Images


        $scfp fsockopen($scip$scport, &$errno, &$errstr30);

        if(!
        $scfp) {

          
        $scsuccs=1;
          echo
        'Offline';

        }

        if(
        $scsuccs!=1){

        //fputs ($scfp, "GET /admin.cgi?sid=$scID&pass=$scpass&mode=viewxml&page=4 HTTP/1.1\r\nHost: $scip:$scport\r\nUser-Agent: User (Mozilla Compatible)\r\nAuthorization: Basic ".base64_encode ("admin:$scpass")."\r\n\r\n");

        //get correct v2 page...
        fputs ($scfp"GET /admin.cgi?sid=".$scID."&pass=".$scpass."&mode=viewxml HTTP/1.1\r\nHost: ".$scip.":".$scport."\r\nUser-Agent: User (Mozilla Compatible)\r\n\r\n");

        while(!
        feof($scfp)) {

          
        $page .= fgets($scfp,4096);

        }

        fclose($scfp);

        // to dump the admin.cgi for debugging... 
        //echo "<!-- ".$page." -->\n\n";

         
        $loop = array("STREAMSTATUS""BITRATE");

         
        $y=0;

         while(
        $loop[$y]!=''){

          
        $pageed ereg_replace(".*<$loop[$y]>"""$page);

          
        $scphp strtolower($loop[$y]);

          $
        $scphp ereg_replace("</$loop[$y]>.*"""$pageed);

          if(
        $loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE)

           $
        $scphp urldecode($$scphp);

          
        $y++;

         }

         
        $pageed ereg_replace(".*<SONGHISTORY>"""$page);

         
        $pageed ereg_replace("</SONGHISTORY>.*"""$pageed);

         
        $songatime explode("<SONG>"$pageed);

         
        $a 0;

         
        $r=1;

         while(
        $songatime[$r]!=""){

          
        $t=$r-1;

          
        $playedat[$t] = ereg_replace(".*<PLAYEDAT>"""$songatime[$r]);

          
        $playedat[$t] = ereg_replace("</PLAYEDAT>.*"""$playedat[$t]);

          
        $song[$t] = ereg_replace(".*<TITLE>"""$songatime[$r]);

          
        $song[$t] = ereg_replace("</TITLE>.*"""$song[$t]);

          
        $song[$t] = urldecode($song[$t]);

          list (
        $artiest$titel) = explode(" - "$song[$t]); 

          
        $rij_kleur = ($a++ % 2) ? "#f5f5f5" "#e8e8e8"

        if (
        $imgKey<>"MYAPI") {

          
        $xml simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=".$artiest."&api_key=".$imgKey);

          
        $trackimg $xml->artist->image[2];

        }

        if (
        $trackimg == "") {

            
        $trackimg "../noIMG.png";

        }



        if ((
        $artiest == "LIVE") && ($titel == "-=ON AIR=-")) {

            
        $trackimg "../live.jpg";

        }



        echo
        '<div style="background-color: '.$rij_kleur.';>

        <p style="width: 65px;"><img style="margin-top:5px; margin-left:5px; border-radius: 100%; border: 1px solid #ff1190; width: 60px; height: 60px;" src="'
        .$trackimg.'" /></p>

        <div style="display:block; margin: -66px 0px 0px 80px; float:left;">

        <i class="fa fa-microphone"></i> <strong>'
        .$artiest.'</strong><br />'.$titel.'</a>

        </div></div>'
        ;



        $r++; }

        }

        ?>
        /* v2 HTML5 / Player test pages DigitalMixNYC, DigitalMixNYCbx | DNAS Status: Now Playing js codes (scaststatus_X.php) | PortForward.com | Upload/Download Speed Test | No-IP.com: Free Dynamic DNS | In the YP | dnasDir */

        Comment


        • #5
          I think that my hoster does not support fsockopen because i still have a
          HTTP ERROR 500

          I made a new script a that one is working for me.

          code:

          <?php
          $sIP = "127.0.0.1";
          $sPort = "8000";
          $sID = "1";
          $sPass = "CHANGEME";
          $imgKey = "MYAPI";

          $a = 0;
          $b = 0;

          function truncate($string, $length, $dots = "...") {
          return (strlen($string) > $length) ? substr($string, 0, $length - strlen($dots)) . $dots : $string;
          }

          $url = file_get_contents("http://$sIP:$sPort/admin.cgi?pass=$sPass&mode=viewxml&page=4&sid=$sID");

          $xml = simplexml_load_string($url);
          foreach( $xml -> SONGHISTORY -> SONG as $Key => $Value ) {

          list ($artist, $title) = explode(" - ", $Value -> TITLE);

          $row_color = ($a++ % 2) ? "#fafafa" : "#f5f5f5";
          $nowplaying = ($b++ % 20) ? "" : "<font style='color:#b2b2b2;font-size:10px;'><strong>NOW PLAYING</strong></font>";

          $LastFM = simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=$artist&api_key=$imgKey");
          $trackimg = $LastFM->artist->image[2];

          if ($trackimg == "") {
          $trackimg = "noIMG.png";
          }

          if ($trackimg == "https://lastfm-img2.akamaized.net/i/u/174s/62ed6ff00329486d8f56656ef783d1aa.png") {
          $trackimg = "noIMG.png";
          }

          if ($artist == "LIVE" AND $title == "-=ON AIR=-") {
          $trackimg = "live.png";
          }

          $ts = $Value -> PLAYEDAT;
          $date = new DateTime("@$ts");

          echo'
          <div style="background-color: '.$row_color.';>
          <p style="width: 65px;"><img style="margin-top:5px; margin-left:5px; border-radius: 100%; border: 1px solid #ff1190; width: 60px; height: 60px;" src="'.$trackimg.'" /></p>
          <div style="display:block; margin: -66px 0px 0px 80px; float:left;">
          <font style="font-size:15px;"><i class="fa fa-microphone"></i> <strong>'.truncate($artist, 100).'</strong></font><br />
          <font style="color:#ff1190;font-size:13px;"><i class="fa fa-headphones"></i> '.truncate($title, 100).'</font><br />' . $nowplaying . '
          </div>
          <div style="display:block; margin: -55px 10px 0px 0px; float:right;">
          <font style="color:#b2b2b2;font-size:10px;"><i class="fa fa-clock-o"></i> ' . $date->format('g:i:s A') . '</font>
          </div>
          </div>';
          }
          ?>

          Comment


          • #6
            Sorry for not using the PHP tag. I used code instead.
            @djSpinnerCee Thanks for the help.

            Comment


            • #7
              @djSpinnerCee: ereg_replace - This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0. http://php.net/manual/en/function.ereg-replace.php

              Comment


              • #8
                @neralex - yeah, the real change that needs to be made is to not use admin.cgi, since all we need here is played history, and we can get that without a password -- i 'll tweak that and post something...
                /* v2 HTML5 / Player test pages DigitalMixNYC, DigitalMixNYCbx | DNAS Status: Now Playing js codes (scaststatus_X.php) | PortForward.com | Upload/Download Speed Test | No-IP.com: Free Dynamic DNS | In the YP | dnasDir */

                Comment


                • #9
                  PHP Code:
                  /* ... making it smart(er) -- leave the password at the default and we'll use /played instead of /admin.cgi */
                  if ($sPass <> "CHANGEME")
                     
                  $url file_get_contents("http://".$sIP.":".$sPort"/admin.cgi?pass=".$sPass."&mode=viewxml&page=4&sid=".$sID);
                  else
                     
                  $url file_get_contents("http://".$sIP.":".$sPort."/played?type=xml&sid=".$sID); 
                  /* v2 HTML5 / Player test pages DigitalMixNYC, DigitalMixNYCbx | DNAS Status: Now Playing js codes (scaststatus_X.php) | PortForward.com | Upload/Download Speed Test | No-IP.com: Free Dynamic DNS | In the YP | dnasDir */

                  Comment


                  • #10
                    Hello Everybody,

                    I want to share my simple Shoutcast v2 Statistics.
                    You can see the script in action here: VIEW

                    In the zip file you will find a index.php, config.php and style.css.
                    Let me know if you need any help.

                    Enjoy the script.

                    Greetings from this side of the world
                    Attached Files

                    Comment


                    • #11
                      Hello Everybody,

                      The DEMO version in the above post is no longer the version that i have uploaded.
                      It still works, but i have upgraded the script to a bit advanced one.

                      The FREE version that is in the zip file, is a playlist only to integrate in your own website.

                      Comment

                      Working...
                      X