title: JavaScript parsing metadata from audio (ICY)
body: <p>I finally found a useful library to parse meta data from an audio stream, here: <a href="https://github.com/ghaiklor/icecast-parser" rel="nofollow noreferrer">https://github.com/ghaiklor/icecast-parser</a>. But still, I can't get the expected response , when I send the headers as in the example below.</p>
  
  <p>The first function makes the request to the radio station / channel and gets the stream:    </p>
  
  <pre><code>_makeRequest() {
      const request = http.request(this.getConfig('url'));
  
      console.log("Making request to: " + this.getConfig('url'));
  
      request.setHeader('Range', 'bytes=0-');
      request.setHeader('User-Agent', 'VLC/2.2.4 LibVLC/2.2.4');
      request.setHeader('Icy-MetaData', '1');
      request.setHeader('Connection', 'close');       
      request.once('response', this._onRequestResponse.bind(this));
      request.once('error', this._onRequestError.bind(this));
  
      request.end();
  
      return this;
  }
  </code></pre>
  
  <p>When a request to a radio station is successfully called, this function is called:</p>
  
  <pre><code>_onRequestResponse(response) {
  
      console.log("Received response!");
      console.log("Headers:");
      console.log(response.headers['content-type']);
  
      const icyMetaInt = response.headers['icy-metaint'];
  
      console.log("icyMetaInt= " + icyMetaInt);
  
      if (icyMetaInt) {
        const reader = new StreamReader(icyMetaInt);
  
        reader.on('metadata', metadata =&gt; {
  
          console.log(metadata);
  
          this._destroyResponse(response);
          this._queueNextRequest(this.getConfig('metadataInterval'));
          this.emit('metadata', metadata);
        });
  
        response.pipe(reader);
        this.emit('stream', reader);
      } else {
        this._destroyResponse(response);
        this._queueNextRequest(this.getConfig('emptyInterval'));
        this.emit('empty');
      }
  
  return this;
  }
  </code></pre>
  
  <p>When I use these functions on this URL (url: '<a href="http://streaming.radionomy.com/70-s-80-sMetal" rel="nofollow noreferrer">http://streaming.radionomy.com/70-s-80-sMetal</a>'), the reply in the console is:</p>
  
  <blockquote>
    <p>audio/mpeg
    icyMetaInt= undefined</p>
  </blockquote>
  
  <p>I understood the most crucial header here is:</p>
  
  <blockquote>
    <p>setHeader('Icy-MetaData', '1')</p>
  </blockquote>
  
  <p>Still, I am not receiving the 'icyMetaInt'. The URL does seem to contain metadata when checking it with other tools.</p>
  
  <p>Any ideas what is going wrong here? Thank you!
  ;</p>