Skip to content

Commit

Permalink
unless statement korrigiert
Browse files Browse the repository at this point in the history
  • Loading branch information
kventil committed Mar 17, 2013
1 parent 85c0e17 commit 2b531d2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions server.rb
Expand Up @@ -13,14 +13,18 @@
get '/*/set/:uri' do
spotify_uri = params[:uri]
uri = URI("http://ws.spotify.com/lookup/1/.json?uri=#{spotify_uri}")

song = JSON.parse(Net::HTTP.get(uri))
out = "#{song["track"]["name"]} by "
song["track"]["artists"].each do |artist|
out = "#{out} #{artist["name"]}"
end


current_song = Song.new(spotify_uri)
"New song is set to: #{out}"
out = "Not a valid song-uri :("

#fetch song-details
response = Net::HTTP.get(uri)
unless response == ""
song = JSON.parse(response)
out = "#{song["track"]["name"]} by "
song["track"]["artists"].each do |artist|
out = "#{out} #{artist["name"]}"
end
current_song = Song.new(spotify_uri)
out = "New song is set to: #{out} :-)"
end
out
end

0 comments on commit 2b531d2

Please sign in to comment.