Code Monkey home page Code Monkey logo

pigs's Introduction

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

pigs's People

Contributors

hodgesmr avatar

Watchers

Jen Norris avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.