Lightweight server for querying and playing from Grooveshark
Ruby JavaScript CSS
Switch branches/tags
Nothing to show
Pull request Compare This branch is 6 commits behind hodgesmr:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
www
.gitignore
Gemfile
Gemfile.lock
LICENSE
PIGSRoutes.rb
PIGSServer.rb
PIGSTuner.rb
README.md

README.md

PIGS

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.

Installation

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.

API

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.

Search

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"
	}
]

Lucky

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"
}

Play

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
}

Control

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
}

FAQ

Does PIGS scale?

No. It's a simple WEBRick servlet. Probably best to only use this in your home for your own convenience.

Is it secure?

No. You're sending plain text back and forth over HTTP.

Do I have to run PIGS on a Raspberry Pi?

No. I created this project to run on my Raspberry Pi, but I've also run it on an Ubuntu box and OS X.

Why do I get a Grooveshark error when trying to run PIGS?

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

A Matt Hodges project

This project is maintained by @hodgesmr