• Stars
    star
    288
  • Rank 143,818 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 14 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.js module for parsing and/or injecting ICY metadata

node-icy

Node.js module for parsing and/or injecting ICY metadata

Build Status

This module offers a Reader class for retrieving the raw audio data and parsing the metadata from an ICY stream (commonly SHOUTcast or Icecast broadcasts).

There's also a Writer class that allows you to inject your own metadata into a data stream, which can then be displayed by another ICY client (like VLC).

But you'll probably be most interested in the Client class that builds off of node's core http module, except this version works with servers that return an ICY HTTP version, and automatically sends an "Icy-MetaData: 1" HTTP header to notify the server that we want metadata, and finally it returns a Reader instance in the "response" event, therefore the "res" object also emits "metadata" events. See the example below to see how it works.

A good use case for this module is for HTML5 web apps that host to radio streams; the <audio> tag doesn't know how to deal with the extra metadata and it is impossible to extract (on the client-side). But a WebSocket connection could be used in conjunction with this module to provide those metadata events to a web browser, for instance.

Installation

Install with npm:

$ npm install icy

Example

Here's a basic example of using the HTTP Client to connect to a remote ICY stream, pipe the clean audio data to stdout, and print the HTTP response headers and metadata events to stderr:

var icy = require('icy');
var lame = require('lame');
var Speaker = require('speaker');

// URL to a known ICY stream
var url = 'http://firewall.pulsradio.com';

// connect to the remote stream
icy.get(url, function (res) {

  // log the HTTP response headers
  console.error(res.headers);

  // log any "metadata" events that happen
  res.on('metadata', function (metadata) {
    var parsed = icy.parse(metadata);
    console.error(parsed);
  });

  // Let's play the music (assuming MP3 data).
  // lame decodes and Speaker sends to speakers!
  res.pipe(new lame.Decoder())
     .pipe(new Speaker());
});

You are also able to add custom headers to your request:

var url = require('url');

// URL to a known ICY stream
var opts = url.parse('http://yourstreamurl.tld/');

// add custom headers
opts.headers = { 'User-Agent': 'Your awesome useragent' };

// connect to the remote stream
icy.get(opts, callback);

API

Client()

The Client class is a subclass of the http.ClientRequest object.

It adds a stream preprocessor to make "ICY" responses work. This is only needed because of the strictness of node's HTTP parser. I'll volley for ICY to be supported (or at least configurable) in the http header for the JavaScript HTTP rewrite (v0.12 of node?).

The other big difference is that it passes an icy.Reader instance instead of a http.ClientResponse instance to the "response" event callback, so that the "metadata" events are automatically parsed and the raw audio stream it output without the ICY bytes.

Also see the request() and get() convenience functions.

request()

request() convenience function. Similar to node core's http.request(), except it returns an icy.Client instance.

get()

get() convenience function. Similar to node core's http.get(), except it returns an icy.Client instance with .end() called on it and no request body written to it (the most common scenario).

Reader()

ICY stream reader. This is a duplex stream that emits "metadata" events in addition to stripping out the metadata itself from the output data. The result is clean (audio and/or video) data coming out of the stream.

Writer()

The Writer class is a duplex stream that accepts raw audio/video data and passes it through untouched. It also has a queue() function that will queue the Writer to inject the metadata into the stream at the next "metaint" interval.

Writer#queue(metadata)

Queues a piece of metadata to be sent along with the stream. metadata may be a String and be any title (up to 4066 chars), or may be an Object containing at least a "StreamTitle" key, with a String value. The serialized metadata payload must be <= 4080 bytes.

parse()

Parses a Buffer (or String) containing ICY metadata into an Object.

stringify()

Takes an Object and converts it into an ICY metadata string.

More Repositories

1

Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
Java
10,438
star
2

NodObjC

The Node.js โ‡† Objective-C bridge
JavaScript
1,396
star
3

proxy-agents

Node.js HTTP Proxy Agents Monorepo
TypeScript
912
star
4

node-spotify-web

Node.js implementation of the Spotify Web protocol
JavaScript
695
star
5

node-speaker

Output PCM audio data to the speakers
JavaScript
634
star
6

plist.js

Mac OS X Plist parser/builder for Node.js and browsers
JavaScript
584
star
7

ansi-canvas

Render a <canvas> node to your terminal
JavaScript
578
star
8

node-lame

Node.js native bindings to libmp3lame & libmpg123
C++
561
star
9

ref

Turn Buffer instances into "pointers"
JavaScript
453
star
10

node-bindings

Helper module for loading your native module's `.node` file
JavaScript
394
star
11

node-time

"time.h" bindings for Node.js
JavaScript
377
star
12

node-applescript

A Node.js module to easily execute arbitrary AppleScript code on Mac OS X.
JavaScript
375
star
13

keypress

Make any Node ReadableStream emit "keypress" events
JavaScript
352
star
14

node-socks-proxy-agent

A SOCKS (v4/v5) proxy `http.Agent` implementation for HTTP and HTTPS
333
star
15

ansi.js

Advanced ANSI formatting tool for Node.js
JavaScript
315
star
16

node-proxy-agent

Maps proxy protocols to `http.Agent` implementations
284
star
17

node-iOS

Native node bindings to iOS functionality (vibrate, acceleromoter, geoservices, etc.)
C++
265
star
18

proxy

An HTTP proxy written with Node.js (think Squid)
254
star
19

gnode

Run node with ES6 Generators, today!
JavaScript
247
star
20

node-throttle

Node.js Transform stream that passes data through at `n` bytes per second
JavaScript
179
star
21

node-wav

`Reader` and `Writer` streams for Microsoft WAVE audio files
JavaScript
174
star
22

superagent-proxy

`Request#proxy(uri)` superagent extension
JavaScript
154
star
23

nx.js

JavaScript runtime for Nintendo Switch homebrew applications
C++
147
star
24

node-nat-pmp

Node.js implementation of the NAT Port Mapping Protocol
JavaScript
129
star
25

node-http-proxy-agent

An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
128
star
26

ref-struct

Create ABI-compliant "struct" instances on top of Buffers
JavaScript
118
star
27

node-cgi

An http/stack/connect layer to invoke and serve CGI executables.
Perl
100
star
28

nTunes

A REST (HTTP) API for interacting with iTunes written in NodeJS.
JavaScript
95
star
29

node-telnet

Telnet implementation for Node.js
JavaScript
87
star
30

node-modbus-stack

A `StreamStack` implementation of the MODBUS protocol, for NodeJS.
JavaScript
87
star
31

node-data-uri-to-buffer

Generate a Buffer instance from a Data URI string
86
star
32

node-upnp-client

UPnP Library for NodeJS.
JavaScript
69
star
33

spotify-uri

Parse and format the various Spotify URI formats
JavaScript
66
star
34

node-ogg

Node.js native binding to libogg
JavaScript
65
star
35

node-pac-proxy-agent

A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
58
star
36

node-agent-base

Turn a function into an `http.Agent` instance
58
star
37

NodeFloyd

An Icecast-compatible server written in NodeJS that streams non-stop "Pink Floyd"!
JavaScript
54
star
38

ref-array

Create C "array" instances on top of Buffers
JavaScript
53
star
39

node-pac-resolver

Generates an asynchronous resolver function from a PAC file
53
star
40

node-get-uri

Returns a `stream.Readable` from a URI string
49
star
41

stat-mode

Offers convenient getters and setters for the fs.stat()'s `mode`
TypeScript
48
star
42

node-gitweb

Directly invoke and serve GitWeb through NodeJS.
JavaScript
40
star
43

util-deprecate

The Node.js `util.deprecate()` function with browser support
JavaScript
37
star
44

ttys

Guaranteed read and write streams to the terminal
JavaScript
36
star
45

blessed-css

CSS engine for `blessed`
TypeScript
35
star
46

node-flv

FLV media container file format encoder and decoder
JavaScript
34
star
47

click-outside

The inverse of the DOM "click" event
HTML
34
star
48

switch-tools

Web app to create "NSP forwarders" for your modded Nintendo Switch
TypeScript
34
star
49

n8.io-old

my blog (deployed to DigitalOcean)
JavaScript
32
star
50

node-drone-joystick

Control AR.Drones using any SDL-compatible Joystick (PS3 Sixaxis, etc.)
JavaScript
31
star
51

SandboxJS

JavaScript "Sandboxes" for the web browser.
JavaScript
31
star
52

node-stream-parser

Generic interruptible "parser" mixin for Transform & Writable streams
JavaScript
29
star
53

node-vorbis

Node.js native binding to libvorbis
JavaScript
28
star
54

node-iTunes

A native node interface to interact with an iTunes process.
C++
28
star
55

node-elf-logger

A Node.js library for configurable HTTP logging following the W3C Extended Log File Format
JavaScript
28
star
56

file-uri-to-path

Convert a `file:` URI to a file path
JavaScript
27
star
57

node-function-name

Set the "name" property of `Function` objects
JavaScript
27
star
58

node-stream-stack

Filter low-level `Stream` instances into stackable, protocol-based streams.
JavaScript
27
star
59

node-buffer-dataview

Minimal DataView implementation that works with Node.js Buffers
JavaScript
26
star
60

node-dlopen

Native bindings to libuv's uv_dlopen() and friends
JavaScript
26
star
61

Simple-Game-Framework

An object-oriented JavaScript API to develop simple, shape and sprite based games.
JavaScript
25
star
62

iheart

iHeart Radio JavaScript API
JavaScript
24
star
63

rocker

Remote Docker: docker -H ssh://[email protected] run -p 80:80 nginx
Shell
23
star
64

once

Creates a Promise that waits for a single event
TypeScript
23
star
65

node-amf

"Action Message Format" read() and write() functions for Buffers
JavaScript
22
star
66

SoundJS

A cross-browser JavaScript sound loading, playing and layering library primarily designed for browser-based games to have a multi-layering sound API.
Haxe
22
star
67

pcre-to-regexp

Converts PCRE regexp strings to JavaScript RegExp instances
JavaScript
21
star
68

node-ctypes

Node.js implementation of "ctypes" to interface with C libs
JavaScript
20
star
69

node-degenerator

Turns sync functions into async functions
19
star
70

node-function-class

Easy `Function` subclasses
JavaScript
19
star
71

nightscout-ps1

Renders your latest blood glucose reading from Nightscout in the command line
JavaScript
19
star
72

nightscout-ps1-c

Tiny C program that formats your latest Nightscout BGL reading for use in your terminal prompt (a.k.a $PS1)
C
18
star
73

ar-drone-socket.io-proxy

Proxy AR.Drone UDP messages over a Socket.io HTTP connection
JavaScript
17
star
74

dotfiles

My dotfiles and such...
Vim Script
17
star
75

path-array

Treat your $PATH like a JavaScript Array
JavaScript
17
star
76

react-tela

Use React to render images, shapes and text to `<canvas>`
TypeScript
17
star
77

node-drone-video

Dump AR.Drone h264 video streams with matching metadata video. Splicing/editing is left up to you.
JavaScript
16
star
78

RetroPie-Profiles

RetroPie plugin to create profiles for save files and save states
Shell
15
star
79

ref-union

Create ABI-compliant "union" instances on top of Buffers
JavaScript
15
star
80

babel-plugin-transform-dirname-filename

Babel plugin that rewrites `__dirname` and `__filename` to static values
JavaScript
15
star
81

mpg123.js

Decode MP3s in the browser using libmpg123 compiled with emscripten
JavaScript
15
star
82

s3fs

Implementation of NodeJS FS interface using Amazon Simple Storage Service (S3).
JavaScript
14
star
83

array-index

Invoke getter/setter functions on array-like objects
JavaScript
14
star
84

node-gitProvider

An http/connect/stack layer to serve the contents of a 'git' repository over HTTP.
JavaScript
14
star
85

n8-make

Opinionated Makefile to build ES6 JS, JSX and Pug files
Makefile
13
star
86

ref-wchar

A ref "type" implementation of `wchar_t *` (a.k.a. wide string) backed by "node-iconv"
JavaScript
13
star
87

nTunesAnywhere

A mobile WebApp to stream your iTunes library from anywhere (using nTunes and jo)!
JavaScript
12
star
88

node-dlfcn

Native bindings to the dynamic shared library linker (dlfcn)
JavaScript
11
star
89

dexcom-share

Async Iterator API for reading blood glucose readings from Dexcom's Share servers
TypeScript
11
star
90

ModuleJS

Asynchronous CommonJS-like Module Loader for web-browsers.
JavaScript
10
star
91

node-objc

This module is deprecated in favor of NodObjC. Use that instead.
C++
9
star
92

vercel-dev-builder

Meta-runtime for Vecel that makes developing Runtimes easier
TypeScript
9
star
93

create

The missing Native.create() functions that ECMA forgot.
JavaScript
9
star
94

nexec

Execute a remote command over HTTP
JavaScript
9
star
95

ansi-hash

Get an ANSI color code for a given string
JavaScript
8
star
96

node-http-stack

A `StreamStack` implementation of the HTTP protocol, for NodeJS.
JavaScript
8
star
97

node-mail-stack

A `StreamStack` subclass that parses raw e-mail messages.
JavaScript
8
star
98

browserify-single-file

Runs browserify transforms/plugins on a single file. Useful for make pipeline tasks.
JavaScript
8
star
99

node-autoreleasepool

A very simple wrapper around the OS X NSAutoreleasePool, for NodeJS
C++
7
star
100

require-string

Turns an arbitrary String into a CommonJS compatible module
JavaScript
7
star