【问题标题】:How can I read icy-url nodejs?我如何阅读 icy-url nodejs?
【发布时间】:2021-04-22 20:32:18
【问题描述】:

我使用 node-icy 提取了标题信息

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

输出:

{
  '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'
}

我只想阅读 icy-url 部分我该怎么做

【问题讨论】:

    标签: javascript node.js icecast shoutcast internet-radio


    【解决方案1】:

    因为res.headers 是一个对象,您可以使用objectName["propertyName"] 来获取icy-url(或objectName.propertyName,但由于-,我会使用第一个。

    所以,这将是:

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

    我也将console.error(); 更改为console.log();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-10
      • 2015-01-04
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2017-09-20
      相关资源
      最近更新 更多