A rudimentary remote jukebox for spotify or rdio (for mac os x only).
Install ruby 1.9.3 and bundler
Clone this repository:
git clone http://github.com/markryall/spotification.git
cd spotification
Install prerequisites:
bundle
There are two processes: the web server process and the player.
The web server allows remote users to search rdio/spotify for tracks (using the their web api), enqueue tracks/albums, control volume and skip tracks. If configured, the web server can also show the recently played tracks for a given user on lastfm (using the lastfm api).
The player monitors the spotify/rdio mac os x applications and the queue (using applescript - hence the mac os x restriction). When spotify/rdio has stopped playing, the player will tell it to start playing the next track in the queue. Note that this queue has nothing to do with the spotify/rdio queue (it is a directory containing a file for each queued track).
So in one terminal session:
rackup
This starts a sinatra application running (on port 9292 by default).
In another terminal session:
./bin/spotification_player
The spotify web services return all results regardless of whether they are available in the country associated with your account. Set the SPOTIFY_TERRITORY to the code associated with your country (AU for australia).
Configuration of the rdio services are more complicated because you need to authenticate to use them. Firstly you need to create an account to get api access: http://developer.rdio.com
Set the environment variables RDIO_CONSUMER_KEY and RDIO_CONSUMER_SECRET according to the values for your application account.
Now in an irb session
require 'rdio'
rdio = Rdio.new [ENV['RDIO_CONSUMER_KEY'], ENV['RDIO_CONSUMER_SECRET']]
p rdio.begin_authentication 'oob'
# browse to the url and authorise your application to access your rdio account
p rdio.complete_authentication '<the code from the site>'
Now set the RDIO_CLIENT_KEY and RDIO_CLIENT_SECRET environment variables from the return values.
You also need to set the SPOTIFICATION_MODE environment variable to rdio (default behaviour is to use spotify).
So easy!
There's really not much too this:
Browse to http://localhost:9292 on a desktop or http://localhost:9292/mobile from a mobile device.
In case you (like me) have configured spotify/rdio to scrobble anything you play to lastfm then you can use this to show recently played tracks (played using spotify, rdio or anything else).
For some unknown reason, lastfm requires an application id to read the recently played tracks for a given user. To use the '/lastfm' route you will need to create a lastfm application with your lastfm account and set the LASTFM_API_KEY and LAST_FM_USER environment variables.
- add lastfm to mobile interface
- make rdio configuration more straigthforward
- replace desktop web interface with a single page
- perhaps introduce ember, angular or something to simplify javascript