javascriptnode.jsicecastshoutcastinternet-radio

How can I read icy-url nodejs?


I pulled the headers information using node-icy

var icy = require('icy');
icy.get('http://46.20.3.201/', function (res) {        
            console.error(res.headers);
        }); 

output:

{
  'icy-notice1': '<BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>',
  'icy-notice2': 'SHOUTcast DNAS/win64 v2.5.5.733<BR>',
  'accept-ranges': 'none',
  'access-control-allow-origin': '*',
  'cache-control': 'no-cache,no-store,must-revalidate,max-age=0',
  connection: 'close',
  'icy-name': 'KRAL POP',
  'icy-genre': 'Various',
  'icy-br': '64',
  'icy-sr': '22050',
  'icy-url': 'http://www.kralpop.com.tr',
  'icy-pub': '0',
  'content-type': 'audio/aacp',
  'icy-metaint': '16384',
  'x-clacks-overhead': 'GNU Terry Pratchett'
}

i just want to read icy-url part how can i do


Solution

  • Because res.headers is an object, you can use objectName["propertyName"] to get icy-url (or objectName.propertyName, but because of the - I'd use the first one.

    So, this would be:

    var icy = require('icy');
    icy.get('http://46.20.3.201/', function (res) {        
        console.log(res.headers["icy-url"]);
    }); 
    

    I have also changed console.error(); to console.log(); as well.