node-spotify-web

Node.js implementation of the Spotify Web protocol

  • 所有者: TooTallNate/node-spotify-web
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

node-spotify-web

Node.js implementation of the Spotify Web protocol

This module implements the "Spotify 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 spotify-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.

API

TODO: document!

License

(The MIT License)

Copyright (c) 2013-2014 Nathan Rajlich <nathan@tootallnate.net>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

主要指标

概览
名称与所有者TooTallNate/node-spotify-web
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2013-01-05 06:06:40
推送于2017-01-12 07:20:59
最后一次提交2015-07-22 11:58:46
发布数11
最新版本名称v1.3.0 (发布于 )
第一版名称v0.0.1 (发布于 )
用户参与
星数698
关注者数55
派生数127
提交数186
已启用问题?
问题数85
打开的问题数34
拉请求数16
打开的拉请求数13
关闭的拉请求数21
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?