Forked from https://github.com/ghaiklor/icecast-parser
- Follow redirects
- Detect charset (latin1 and utf8 only, for now)
Readme from ghaiklor:
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.
- Opens async connection to URL and gets response with radio stream and metadata. Then pipes the response to
Transformstream for processing;
- Getting metadata from stream is implemented as
Transformstream, so you can pipe it to another Writable\Duplex\Transform;
- Once it receives metadata,
metadataevent triggers with metadata object;
- After metadata is received, connection to radio station closes automatically, so you will not spend a lot of traffic;
- But you can set
keepListenflag in configuration object and continue listening radio station;
- Auto updating metadata from radio station by interval in economical way (connection is opens when time has come);
- Metadata parsed as a
- When you create a new instance, you get
EventEmitter. So you can subscribe to other events;
- Easy to configure and use;
You can install icecast-parser from npm.
npm install icecast-parser
Get your first metadata from radio station.
You can provide additional parameters to constructor:
url- by default empty and REQUIRED. Otherwise, you will get an error.
userAgent- by default
keepListen- by default
false. If you set to
true, then response from radio station will not be destroyed and you can pipe it to another streams. E.g. piping it to the
autoUpdate- by default
true. If you set to
false, then parser will not be listening for recent updates and immediately close the stream. So that, you will get a metadata only once.
notifyOnChangeOnly- by default
false. If you set both
true, it will keep listening the stream and notifying you about metadata, but it will not notify if metadata did not change from the previous time.
errorInterval- by default 10 minutes. If an error occurred when requesting, the next try will be executed after this interval. Works only if
emptyInterval- by default 5 minutes. If the request was fullfiled but the metadata field was empty, the next try will be executed after this interval. Works only if
metadataInterval- by default 5 seconds. If the request was fullfiled and the metadata was present, the next update will be scheduled after this interval. Works only if
You can subscribe to following events:
endevent triggers when connection to radio station was ended;
errorevent triggers when connection to radio station was refused, rejected or timed out;
emptyevent triggers when connection was established successfully, but the radio station doesn't have metadata in there;
metadataevent triggers when connection was established successfully and metadata is parsed;
streamevent triggers when response from radio station returned and successfully piped to