npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-internet-radio

v0.2.1

Published

Node.js module to get Now Playing information from an internet radio stream.

Downloads

459

Readme

Get internet radio stream details via Node.js. Node.js module to get Now Playing information from an internet radio stream in the form of the following object:

{ listeners: '89',
  bitrate: '128',
  title: 'Die Antwoord - I Fink U Freaky',
  fetchsource: 'SHOUTCAST_V1' }

The syntax is simple:

getStationInfo(url, callback, [method]);

Install

npm install node-internet-radio

This Node.js module supports three different methods to fetch the station details of an internet radio stream. All but fetching details from the raw audio stream give you the currently playing track, bitrate, and listener count.

| Method | StreamSource | Track | Bitrate | Listeners | Headers | | ------ | ------ | -----|------- | ---------- | ---------- | | Shoutcast V1 | StreamSource.SHOUTCAST_V1 | ✓ | ✓ | ✓ | X | | Shoutcast V2 | StreamSource.SHOUTCAST_V2 | ✓ | ✓ | ✓ | X | | Icecast | StreamSource.ICECAST | ✓ | ✓ | ✓ | X | | Raw Stream (icy metadata) | StreamSource.STREAM | ✓ | X | X | ✓ |

Examples

If you have an audio stream and don't know what approach to take then simply omit the last method parameter and it will use all available options and return the first one that completes. At the very least the stream method will return something from a valid stream, but it will not support the Bitrate and Listener count.

var internetradio = require('node-internet-radio');
var testStream = "http://23.27.51.2:6699";
internetradio.getStationInfo(testStream, function(error, station) {
  console.log(station);
});

While this approach is easy, it's not efficient. You should not be hitting invalid resources and slurping down the raw audio feed each time if you don't need to.

The approach you should take is to find out what source method you want to utilize, cache it, and then only use that going forward. Think about going through each method in order of preference (probably V1, V2, Icecast, Stream) and take note of that for next time.

To fetch the station details using a specific method simply pass it as the last argument using one of the StreamSource constants above.

internetradio.getStationInfo("http://coolstream.net/", function(error, station) {
  console.log(station);
}, internetradio.StreamSource.SHOUTCAST_V1);

Server headers

If you are interested in the server headers instead of just the now-playing information use StreamSource.STREAM and you'll get the server headers from the stream.

{ title: 'Tosca - Zuri',
  fetchsource: 'STREAM',
  headers:
   { 'icy-br': '128',
     'icy-genre': 'Ambient Chill',
     'icy-name': 'Groove Salad',
     'icy-notice1': '<BR>This stream requires <a href="http',
     'icy-notice2': 'SHOUTcast Distributed Network Audio Server/Linux v1.9.5<BR>',
     'icy-pub': '0',
     'icy-metaint': '45000' } }