Top 50 playlists, last.fm and youtube links

This commit is contained in:
magnolia-fan
2011-11-26 18:18:02 +04:00
parent 705b4cfbc2
commit 4ade7fa77f
6 changed files with 23 additions and 6 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ class ArtistController < ApplicationController
return render json: { status: 'fail', html: render_compact_partial(:fail) }
end
response.headers['Cache-Control'] = 'public, max-age='+1.week.seconds.to_s
# response.headers['Cache-Control'] = 'public, max-age='+1.week.seconds.to_s
render json: {
status: @artist.status_str,
artist: @artist,
+8
View File
@@ -79,6 +79,14 @@ class LastFmController < ApplicationController
render :json => { :status => r['error'].nil? ? 'success' : r }
end
def self.top_playlist artist
playlist = Playlist.create(name: "#{artist.name}: Last.fm TOP")
LastFM::Artist.get_top_tracks(artist: artist.name)["toptracks"]["track"].each do |track|
tracks = Track.joins(:album, :artists).where(name: track["name"], "track_artists.artist_id" => artist.id)
PlaylistItem.create(playlist_id: playlist.id, track_id: tracks.first.id) unless tracks.empty?
end
end
def autocomplete
autocomplete = getSuggestions(params[:query])
return render :nothing => true if autocomplete.nil?