A democratic, crowd-controlled music player for the workplace.
sequel
and sqlite3
gems to be installed.
apt-get install libsqlite3-dev
)ruby-mpd
gem to be installed.
faye
gem to be installed.haml
gem to be installed.taglib-ruby
gem to be installed
taglib
installed along with header files.sinatra
, and moneta
gems installed.
thin
and use that to run the web server.gem install rb3jay
In summary:
sudo apt-get install build-essential sqlite3 libsqlite3-dev mpd mpc ruby ruby-dev
sudo gem install sqlite3 sequel ruby-mpd faye haml sinatra moneta thin rb3jay
rb3jay --help
for command-line options.The rb3jay server is a headless application that manages songs, playlists, voting, and actually plays the music (via MPD). All communication with the server occurs through TCP sockets carrying a JSON object.
Every query you send to the server is identified by a cmd
property
describing your intent, sometimes along with additional arguments.
The supported commands are summarized here, and described in detail below that.
Querying
playlists
: get a list of all playlists, with summary informationplaylist
: get a list of all songs for a playlistplaying
: get details about the currently-playing song and playlistupcoming
: see a summary of upcoming songssongs
: get a summary of all songs in the librarysong
: get detailed information about a particular songsearch
: find songs in the libraryPlayback Control
stop
: pause playbackplay
: resume playback, or start a particular playlist or songnext
: skip to the next songback
: restart the current song, or go to a previous songseek
: jump to a particular playback timewant
: add a particular song to the upcoming playlistnope
: remove a particular song from the upcoming playlistVoting
love
: indicate +2 for a song for a particular userlike
: indicate +1 for a song for a particular userzero
: indicate +0 for a song for a particular userbleh
: indicate -1 for a song for a particular userhate
: indicate -2 for a song for a particular userModifying the Library
update
: check for new/changed/deleted songs in the librarymakePlaylist
: create a new playlisteditPlaylist
: update a playlistkillPlaylist
: delete a playlisteditSong
: update metadata for a particular songkillSong
: remove a song from the libraryAdmin
removeUser
: clear all actions by a particular userhistory
: show the log of all actions taken in a particular time periodquit
: quit the server{ "cmd":"playlists" }
→ array of playlists
Returns a JSON array of all JSON playlist objects in the system, sorted by name.
Each playlist summary object looks like the following:
{
"name" : "Party Time",
"songs" : 42,
"code" : null
}
If the playlist is "live" the code
key will have a string of the query
used to generate the playlist.
Use the playlist
query to get the list of songs for a particular playlist.
{"cmd":"playlist", "name":"…"}
→ playlist details
Returns a JSON object identical to those returned by playlists
,
except that the songs
key is an array of of JSON song summary objects
for the playlist.
Songs are sorted by artist, album, track, and title. Each song summary object looks like the following:
{
"file" : "Chicane/Giants/12 Titles.m4a",
"title" : "Titles",
"artist" : "Chicane",
"album" : "Giants",
"genre" : "Dance",
"date" : 2010,
"time" : 261,
"rank" : 0.6327,
"artwork" : "Chicane/Giants/12 Titles.m4a.jpg"
}
The length
value is the duration the song in seconds.
The rank
value is the relative value of the song (based on complex voting),
and is normalized between 0 and 1 (inclusive).
Metadata missing for a song (e.g. no year
information) will be missing from
the object; there will not be a key with a null
value.
{"cmd":"playing"}
→ array of song summaries
Returns a song summary object.
{"cmd":"upcoming"}
see a summary of upcoming songs
{"cmd":"songs"}
→ array of song summaries
Returns a JSON array of JSON song summary objects for every song tracked in the library.
Songs are sorted by artist, album, track, and title. Each song summary object looks like the following:
{
"file" : "Chicane/Giants/12 Titles.m4a",
"title" : "Titles",
"artist" : "Chicane",
"album" : "Giants",
"genre" : "Dance",
"date" : 2010,
"time" : 261,
"rank" : 0.6327,
"artwork" : "Chicane/Giants/12 Titles.m4a.jpg"
}
{"cmd":"song", "file":…}
→ song details
Returns a JSON object with detailed information about the song with the supplied file.
Song details look like the following:
{
"file" : "Chicane/Giants/12 Titles.m4a",
"title" : "Titles",
"artist" : "Chicane",
"album" : "Giants",
"genre" : "Dance",
"date" : 2010,
"time" : 261,
"rank" : 0.6327,
"artwork" : "Chicane/Giants/12 Titles.m4a.jpg",
"modified" : "2015-07-29 04:46:01 UTC",
"track" : 12,
"composer" : "N. Bracegirdle/J. Hockley",
"disc" : 1,
"albumartist" : "Chicane",
"bpm" : 134
}
{"cmd":"search", "query":"…"}
→ array of song summaries
Returns a JSON array of JSON song summary objects for every song tracked in the library.
The simple query
field is matched loosely against title
, artist
, album
, genre
, and year
.
{"cmd":"stop"}
pause playback
{"cmd":"play", …}
To start or resume playback from the current song list, issue this command with no additional parameters.
{"cmd":"next"}
skip to the next song
{"cmd":"back"}
restart the current song, or go to a previous song
{"cmd":"seek", "time":4.71}
jump to a particular playback time
{"cmd":"want"}
add a particular song to the upcoming playlist
{"cmd":"nope"}
remove a particular song from the upcoming playlist
Each user of rb3jay can express their opinion about a song. The relative desirability of each song is based on a complex formula taking overall voting into account.
The five voting levels are:
love
+2 : I'm not tired of this song, play it every day.like
+1 : This song should come up more often than others.zero
0 : I'm okay with this song.bleh
-1 : I'm getting tired of this song. Play it every other week.hate
-2 : If it were up to me, this song would never be played.Voting on a song requires the song's file and the name of the user who is voting:
{
"cmd" : "like",
"file" : "Chicane/Giants/12 Titles.m4a",
"user" : "phrogz"
}
{"cmd":"makePlaylist", "name":"…"}
The name
parameter is the name of the new playlist.
You may optionally include a code
parameter set to a string to create this
as a "live" playlist.
{"cmd":"editPlaylist", "name"="…", …}
Update the information about a playlist, or its song contents.
Along with the editPlaylist
command and the name
attribute identifying the
playlist to modify, you must supply one or more of the following changes to make:
{…, "newName"="…"}
— rename the playlist.{…, "code"="…"}
— set the query to use for a "live" playlist.null
to make this a normal playlist.{…, "add"=["file1","file3","file2"]}
— add the songs (specified by song file
).{…, "remove"=["file7","file3"]}
— remove the songs (specified by song file
).{"cmd":"killPlaylist", "name"="…"}
Delete a playlist, specified by name.
{"cmd":"editSong", "file"="…"}
update metadata for a particular song
{"cmd":"removeUser"}
Clear all actions (especially votes) by a particular user.
{"cmd":"history"}
show the log of all actions taken in a particular time period
{"cmd":"quit"}
Cleanly shut down the server. Does not send a response.
Gavin Kistner [email protected]