1
0
mirror of https://github.com/danbee/mpd-client synced 2025-03-04 08:39:09 +00:00
mpd-client/mpd_client.rb
2013-09-04 15:13:23 +01:00

39 lines
726 B
Ruby

require 'bundler'
ENV['RACK_ENV'] ||= 'development'
Bundler.require(:default, ENV['RACK_ENV'])
require 'json'
require 'cgi'
require './models/album'
require './models/artist'
class MPDClient < Sinatra::Base
register Sinatra::Namespace
namespace '/api' do
get '/albums' do
JSON Album.all.map(&:to_h)
end
get '/artists/:artist' do
JSON Album.by_artist(CGI.unescape(params[:artist])).sort.map(&:to_h)
end
#get '/albums/:album' do
#JSON get_songs_by_album(CGI.unescape(params[:album]))
#end
#get '/artists/:artist/:album' do
#JSON get_songs_by_album(CGI.unescape(params[:album]))
#end
get '/artists' do
JSON Artist.all.map(&:to_h)
end
end
end