spotify-node-applescript

Control Spotify on Mac OSX with NodeJS and AppleScript.

spotify-node-applescript

Control Spotify on Mac OSX with NodeJS and AppleScript.

$ npm install spotify-node-applescript
$ npm test

Open track with Spotify URI uri.

var spotify = require('spotify-node-applescript');
 
spotify.playTrack('spotify:track:3AhXZa8sUQht0UEdBJgpGc', function(){
    // track is playing 
});

Get the current track. callback is called with the current track as second argument.

var spotify = require('spotify-node-applescript');
 
spotify.getTrack(function(errtrack){
 
    /*
    track = {
        artist: 'Bob Dylan',
        album: 'Highway 61 Revisited',
        disc_number: 1,
        duration: 370,
        played count: 0,
        track_number: 1,
        starred: false,
        popularity: 71,
        id: 'spotify:track:3AhXZa8sUQht0UEdBJgpGc',
        name: 'Like A Rolling Stone',
        album_artist: 'Bob Dylan',
        spotify_url: 'spotify:track:3AhXZa8sUQht0UEdBJgpGc' }
    }
    */
 
});

Get player state.

var spotify = require('spotify-node-applescript');
 
spotify.getState(function(errstate){
    /*
    state = {
        volume: 99,
        position: 232,
        state: 'playing'
    }
    */
});

Jump to a specific second of the current song.

var spotify = require('spotify-node-applescript');
 
spotify.jumpTo(15, function() {
    console.log('Jumped 15th second of the song');
});

Resume playing current track.

Pause playing track.

Toggle play.

Play next track.

Play previous track.

Turn volume up.

Turn volume down.

Sets the volume.

var spotify = require('spotify-node-applescript');
 
spotify.setVolume(42, function() {
    spotify.getState(function(errstate) {
        console.log(state.volume);
    });
});

Reduces audio to 0, saving the previous volume.

Returns audio to original volume.

Check if Spotify is running.

var spotify = require('spotify-node-applescript');
 
spotify.isRunning(function(errisRunning){
    console.log(isRunning); // true 
});

Returns the file path to the current artwork as PNG. The PNG files are cached in ~/Library/Caches/TemporaryItems.

var spotify = require('spotify-node-applescript');
 
spotify.getArtwork(function(errartworkPath) {
    console.log('Current artwork is at %s', artworkPath);
});

MIT