posting RDS data directly to shoutcast server.

dooly

New Member
There is a way to post directly to the shoutcast server the track that is playing, as well as getting data via requests.
I remember a long time ago the url code went something like:
Code:
http://x.x.x.x:xxxx/admin.cgi?pass=****&mode=updinfo&url=songurl&song=songname&artist=artistname

Do we have a current list somewhere of the input url array, query modes, and the output arrays?

EDIT:
also, is there a link in the dnas to get the coded password, or the hash to generate the encoded password for url requests
 
I have to note that I had to format it Artist - track with a dash in the middle and a space before and after the dash to parse out the "unknown" off the title.
 
Last edited:
here is my code I came up with. I use a computer at the station to query the website for the xml file that the DJ program I have (Jazler) dumps on my website, then I strip out the data and send it to shoutcast dnas. I have like a 10-12 second delay of updating, but acceptable. I do send a little packet out (current time) that doesn't get used for anything other than forcing the browser not to cache the xhr send/response. It loads the track's database ID in a hidden element, then it compares it every 10 seconds then if it sees a different id number, it executes the update code.

on a computer, I installed ubuntu and installed apache and php.

here is what I put in the index.html:

HTML:
 <p id="innn">
                
          </p>

 <div id="trackNowId" style="display:none;"></div>
        
        
         <!--- then at the bottom of the page before the </body> tag:
         Jquery is required, I downloaded the jquery.js file from my bootstrap4 web page--->
         <script src="jquery.min.js"></script>
<script>
$(document).ready(function(){
 
var auto_refresh = setInterval(function() {loadCurrentTrackId(); }, 10000);

});
function loadCurrentTrackId() {
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {

    if (this.readyState == 4 && this.status == 200) {
var oldtrk="";
var tsttrk="";
var oldtrk = document.getElementById('trackNowId').innerHTML;
var tsttrk= this.responseText;   
 if (oldtrk != tsttrk){
 document.getElementById('trackNowId').innerHTML = tsttrk;
loadXMLDoc();
}
    }
  };
  xhr.open("GET", "trackid.php"+ ((/\?/).test("trackid.php") ? "&" : "?") + (new Date()).getTime());
  xhr.setRequestHeader( 'CacheControl', false );
  xhr.send();

}
function loadXMLDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {

    if (this.readyState == 4 && this.status == 200) {
     document.getElementById('innn').innerHTML = this.responseText;
    }
  };

  xhttp.open("GET", "update.php"+ ((/\?/).test("update.php") ? "&" : "?") + (new Date()).getTime());
  xhttp.setRequestHeader( 'CacheControl', false );
  xhttp.send();

}
</script>

here is the "trackid.php":

PHP:
<?php
$xml = simplexml_load_file("http://www.knkl.net/NowOnAir.xml?=".time());
echo $xml->Event->Song->Jazler['ID'];
?>

and here is my update.php that updates the code:



PHP:
<?php
// SHOUTCAST UPDATER
//BY AUDIOSPECIFIC INTERNET SYSTEMS///
// Load xml file to parse in the beginning and set empty variables
$xml= simplexml_load_file("http://www.knkl.net/NowOnAir.xml?=".time());

// parse and load jazler db info of song...
$siid = $xml->Event->Song->Jazler['ID'];
$sTittle= $xml->Event->Song['title'];
$sArtist= $xml->Event->Song->Artist['name'];

/// format the text string to send:

$uText=$sArtist." - ".$sTittle;


$ip = "DNAS_IP_NUMBER"; // Server Address
$port = "DNAS_PORT"; // Server Port that is used to access the home page of the shoutcast dnas server
$pass = "shoutcast_admin_password"; // Admin Password


$song = urlencode($uText);
$song = str_replace("+", "%20", $song);
        $fp = @fsockopen($ip,$port,$errno,$errstr,4);
        if (!$fp) {
            print "Error: cant get server, please check that server is online";
        } else {
            fputs($fp, "GET /admin.cgi?pass=" . $pass . "&mode=updinfo&song=" . $song . " HTTP/1.0\r\n");
            fputs($fp, "User-Agent: Mozilla\r\n\r\n");
            fclose($fp);
echo "update sent:  ".$uText;
}
 
Top