Tracks import
This commit is contained in:
@@ -4,5 +4,12 @@ module Api
|
||||
album = Album.find(params[:id])
|
||||
redirect_to album.load_pic
|
||||
end
|
||||
|
||||
def show
|
||||
album = Album.find(params[:id])
|
||||
return render json: { fail: true } if album.nil?
|
||||
|
||||
render json: album.dump_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
module Api
|
||||
class SearchController < ApplicationController
|
||||
def complete
|
||||
return render json: { suggestions: [] } if params[:query].to_s.length == 0
|
||||
|
||||
suggestions = (Robbie::Autocomplete.complete(params[:query].to_s) || [])
|
||||
render json: {
|
||||
query: params[:query],
|
||||
suggestions: suggestions
|
||||
}
|
||||
end
|
||||
|
||||
def wtfis
|
||||
result = (Robbie::Autocomplete.search(params[:q].to_s) || []).first
|
||||
unless result.nil?
|
||||
if result.instance_of? Robbie::Artist
|
||||
artist = Artist.find_or_create_by_rovi_id(result.id)
|
||||
puts artist.inspect
|
||||
unless artist.name?
|
||||
artist.import
|
||||
end
|
||||
return render json: { found: "/artist/#{result.name.gsub(" ", "+")}" }
|
||||
elsif result.instance_of? Robbie::Album
|
||||
album = Album.find_or_create_by_rovi_id(result.id)
|
||||
unless album.title?
|
||||
album.import
|
||||
end
|
||||
return render json: { found: "/album/#{album.id}" }
|
||||
end
|
||||
end
|
||||
|
||||
render json: { found: nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user