ghaiklor / icecast-parser

Node.js module for getting and parsing metadata from SHOUTcast/Icecast radio streams
MIT License
70 stars 18 forks source link
icecast icecast-parser metadata nodejs parse radio-station radio-stream shoutcast

icecast-parser

Build Status Code Coverage

GitHub followers Twitter Follow

Node.js module for getting and parsing metadata from SHOUTcast/Icecast radio streams.

NOTE: the server that serves radio station stream must support Icy-Metadata header. If that is not the case, this parser cannot parse the metadata from there.

Features

Getting Started

You can install icecast-parser from npm.

npm install icecast-parser

Get your first metadata from radio station.

import { Parser } from 'icecast-parser';

const radioStation = new Parser({ url: 'https://live.hunter.fm/80s_high' });
radioStation.on('metadata', (metadata) => process.stdout.write(`${metadata.get('StreamTitle') ?? 'unknown'}\n`));

Configuration

You can provide additional parameters to constructor:

import { Parser } from 'icecast-parser';

const radioStation = new Parser({
  autoUpdate: true,
  emptyInterval: 5 * 60,
  errorInterval: 10 * 60,
  keepListen: false,
  metadataInterval: 5,
  notifyOnChangeOnly: false,
  url: 'https://live.hunter.fm/80s_high',
  userAgent: 'Custom User Agent',
});

radioStation.on('metadata', (metadata) => process.stdout.write(`${metadata.get('StreamTitle') ?? 'unknown'}\n`));

Events

You can subscribe to following events: end, error, empty, metadata, stream.

License

MIT