Skip to content

Commit

Permalink
it's included
Browse files Browse the repository at this point in the history
  • Loading branch information
holman committed Oct 31, 2011
1 parent 78399ad commit 68d0c56
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/play/app/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class App < Sinatra::Base
end

get "/api/say" do
Play::Client.say(params[:message])
Client.say(params[:message])
{ :success => "Okay." }.to_json
end

Expand All @@ -21,7 +21,7 @@ class App < Sinatra::Base
end

post "/api/import" do
if Play::Library.import_songs
if Library.import_songs
{ :success => 'true' }.to_json
else
error "Had some problems importing into Play. Uh-oh."
Expand All @@ -30,7 +30,7 @@ class App < Sinatra::Base

post "/api/add_song" do
api_authenticate
artist = Play::Artist.find_by_name(params[:artist_name])
artist = Artist.find_by_name(params[:artist_name])
if artist
song = artist.songs.find_by_title(params[:song_title])
if song
Expand All @@ -46,7 +46,7 @@ class App < Sinatra::Base

post "/api/add_artist" do
api_authenticate
artist = Play::Artist.find_by_name(params[:artist_name])
artist = Artist.find_by_name(params[:artist_name])
if artist
{:song_titles => artist.enqueue!(api_user).collect(&:title),
:artist_name => artist.name}.to_json
Expand All @@ -57,7 +57,7 @@ class App < Sinatra::Base

post "/api/add_album" do
api_authenticate
album = Play::Album.find_by_name(params[:name])
album = Album.find_by_name(params[:name])
if album
album.enqueue!(api_user)
{:artist_name => album.artist.name,
Expand All @@ -84,24 +84,24 @@ class App < Sinatra::Base
end

post "/api/volume" do
if Play::Client.volume(params[:level])
if Client.volume(params[:level])
{ :success => 'true' }.to_json
else
error "There's a problem adjusting the volume."
end
end

post "/api/pause" do
if Play::Client.pause
if Client.pause
{ :success => 'true' }.to_json
else
error "There's a problem pausing."
end
end

def api_user
Play::User.find_by_login(params[:user_login]) ||
Play::User.find_by_alias(params[:user_login])
User.find_by_login(params[:user_login]) ||
User.find_by_alias(params[:user_login])
end

def api_authenticate
Expand Down

0 comments on commit 68d0c56

Please sign in to comment.