Top 50 playlists, last.fm and youtube links
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user