PIGS (Pi Grooveshark) is both a server-side and client side application that leverages the Grooveshark RubyGem to create a convenient way to play music on-demand. You can run PIGS on any Unix-like host; I created this project to run on a Raspberry Pi.
PIGS requires Ruby and Bundler to run. My Raspbian install didn't come with those out of the box, so you may need to install those first to get eveything up and running.
PIGS also relies on mplayer for audio output, so make sure you have that installed as well:
sudo aptitude install mplayer
Now you are ready to install and run PIGS:
git clone https://github.com/hodgesmr/PIGS.git ~/PIGS
cd ~/PIGS
bundle install
ruby PIGSServer.rb
You may also specify a port as a runtime argument. The default port is 9001.
Once PIGS is running, you can either use its web interface (simply point a browser at the PIGS host) or interact with its exposed methods directly.
If you wish to create your own application to interact with PIGS, you can use the exposed API to make HTTP requests. All requests take plain text and respond with JSON.
Asks PIGS for search results based on a query string. Returns a JSON array of the results, or null.
Request:
$.ajax({
url: './search',
type: 'POST',
contentType: 'text/plain',
dataType: 'json',
data: 'What Does The Fox Say'
});
Response:
[
{
"artistID":"1885806",
"albumName":"Summer Single",
"artistName":"Ylvis",
"track":"1",
"albumID":"9226785",
"songName":"What Does The Fox Say?",
"songID":"39727231"
},
{
"artistID":"2787509",
"albumName":"Instalok",
"artistName":"Instalok",
"track":"0",
"albumID":"9126419",
"songName":"What Does Teemo Say(Ylvis the Fox Parody)",
"songID":"39747605"
},
{
"artistID":"2853426",
"albumName":"parody",
"artistName":"instalok",
"track":"0",
"albumID":"9259327",
"songName":"what does teemo say (Ylvis-the fox parody)",
"songID":"39823019"
},
{
"artistID":"2854700",
"albumName":"What Does The Fox Say (YouTube Version - Karaoke) (Ylvis Cover)",
"artistName":"Ylvies",
"track":"1",
"albumID":"9262773",
"songName":"The Fox karaoke instrumental ",
"songID":"39832995"
},
{
"artistID":"1885806",
"albumName":"UNKNOWN",
"artistName":"Ylvis",
"track":"0",
"albumID":"9233828",
"songName":"What Does The Fox Say",
"songID":"39893240"
}
]
Asks PIGS to play a song based on a query string. Returns a JSON object of the song, or null.
Request:
$.ajax({
url: './lucky',
type: 'POST',
contentType: 'text/plain',
dataType: 'json',
data: 'What Does The Fox Say'
});
Response:
{
"artistID":"1885806",
"albumName":"Summer Single",
"artistName":"Ylvis",
"track":"1",
"albumID":"9226785",
"songName":"What Does The Fox Say?",
"songID":"39727231"
}
Asks PIGS to play a song based on an ID. Returns a JSON encoded success messsage.
Request:
$.ajax({
url: './play',
type: 'POST',
contentType: 'text/plain',
dataType: 'json',
data: '39727231'
});
Response:
{
"success":true
}
Asks PIGS to execute a playback command. The currently supported commands are stop
and pause_unpause
. Returns a JSON encoded success message.
Request:
$.ajax({
url: './control',
type: 'POST',
contentType: 'text/plain',
dataType: 'json',
data: 'stop'
});
Response:
{
"success":true
}
No. It's a simple WEBRick servlet. Probably best to only use this in your home for your own convenience.
No. You're sending plain text back and forth over HTTP.
No. I created this project to run on my Raspberry Pi, but I've also run it on an Ubuntu box and OS X.
The API is constantly changing. Thankfully, the grooveshark gem is also actively maintained. Try updating the gem. If that doesn't work, feel free to log an issue.
gem update grooveshark
This project is maintained by @hodgesmr