Skip to content

Instantly share code, notes, and snippets.

@walkah
Created July 1, 2014 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walkah/caa4d1e2e6783d42c60f to your computer and use it in GitHub Desktop.
Save walkah/caa4d1e2e6783d42c60f to your computer and use it in GitHub Desktop.
dashing-rdio
var applescript = require('applescript');
var Rdio = require('./rdio');
var DashingClient = require('dashing-client');
var rdio = new Rdio(['CONSUMER_KEY', 'CONSUMER_SECRET']);
var dashing = new DashingClient("http://localhost:3030", "YOUR_AUTH_KEY");
var script = 'tell application "Rdio" to get the key of the current track';
var currentTrack = '';
function updateTrack() {
applescript.execString(script, function(err, ret) {
if (ret != currentTrack) {
currentTrack = ret;
console.log('Updating to ' + currentTrack);
rdio.call('get', { 'keys': ret }, function(err, data) {
var song = data['result'][ret];
dashing.send('rdio', {
track: song['name'],
artist: song['artist'],
album: song['album'],
cover: song['icon']
});
});
}
});
}
updateTrack();
setInterval(updateTrack, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment