yfitops-web

0.2.1 • Public • Published

yfitops-web

A fork of the node.js implementation of the Spotify Web protocol

This module implements the "yfitops web" WebSocket protocol that is used on Spotify's Web UI.

This module is heavily inspired by the original open-source Python implementation: Hexxeh/spotify-websocket-api.

Installation

$ npm install yfitops-web

Example

Here's an example of logging in to the Spotify server and creating a session. Then requesting the metadata for a given track URI, and playing the track audio file through the speakers:

var lame = require('lame');
var Speaker = require('speaker');
var Spotify = require('spotify-web');
var uri = process.argv[2] || 'spotify:track:6tdp8sdXrXlPV6AZZN2PE8';
 
// Spotify credentials...
var username = process.env.USERNAME;
var password = process.env.PASSWORD;
 
Spotify.login(username, password, function (err, spotify) {
  if (err) throw err;
 
  // first get a "Track" instance from the track URI
  spotify.get(uri, function (err, track) {
    if (err) throw err;
    console.log('Playing: %s - %s', track.artist[0].name, track.name);
 
    // play() returns a readable stream of MP3 audio data
    track.play()
      .pipe(new lame.Decoder())
      .pipe(new Speaker())
      .on('finish', function () {
        spotify.disconnect();
      });
 
  });
});

See the example directory for some more example code.

Readme

Keywords

none

Package Sidebar

Install

npm i yfitops-web

Weekly Downloads

1

Version

0.2.1

License

MIT

Last publish

Collaborators

  • christophior