Script untuk mengambil lagu-lagu yang sudah diputar di Shoutcast Server v2.5.x. Sebagai contoh kita akan mengambil data dari lagu-lagu yang sudah diputar di Radio Karo Online.

Script PHP (lagu.php)

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Script Lagu Shoutcast v2.5 - Jaranguda.com</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <style type="text/css">
    body {
        padding-top: 5rem;
    }
    </style>
  </head>
 
  <body>
    <main role="main" class="container">
    <h4>Radio Karo Online</h4><hr>
        <div class="row">
            <div class="col-md-12">
                <?php
                    function fungsiCurl($url){
                       $data = curl_init();
                       curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
                       curl_setopt($data, CURLOPT_URL, $url);
                       curl_setopt($data, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0");
                       $hasil = curl_exec($data);
                       curl_close($data);
                       return $hasil;
                   }
 
                   $linkUrl = fungsiCurl('http://radio.karo.or.id:2012/played.html');
 
                   $tabel = explode('<table border=0 cellpadding=2 cellspacing=2>', $linkUrl);
                   $akhirTabel = explode ('</table>',$tabel[0]);
                   preg_match_all("'<tr>(.*?)</tr>'si",$akhirTabel[1], $match);
                   echo '<table class="table table-hover table-striped table-sm">';
 
                   foreach($match[1] as $val => $el)
                   {
                    echo "<tr>" . $el."</tr>";
                    }
                    echo "</table>";
                ?>
            </div>
        </div>
    </main>
 
</body>
</html>

Keterangan Code

Bagian code yang perlu diubah adalah

linkUrl => link ke shoutcast server beserta portnya

Tampilan script diatas

current playing song shoutcast

Script diatas untuk format tabelnya menggunakan Bootstrap 4, bisa diganti dengan css framework apa saja, ataupun tanpa framework.

Menghilangkan Current Song

Untuk menghilangkan baris current song dari script diatas, ubah looping foreach menjadi

foreach($match[1] as $val => $el)
{
    if($val !== 0 and $val !== 1) {
    echo "<tr>" . $el."</tr>";
    }
}

shoutcast 2.5 tanpa current song

Join the Conversation

1 Comment

Your email address will not be published. Required fields are marked *

  1. hey tommy, i like this script, but i need your help. please contact me telegram @xpudvalvo