1
0
Fork 0
oldhaven/app/controllers/track_controller.rb

20 lines
716 B
Ruby
Raw Normal View History

class TrackController < ApplicationController
2011-04-08 19:42:14 +00:00
require 'net/http'
require 'uri'
def listen
2011-04-10 03:17:34 +00:00
pp track = Track.where(:id => params[:id].to_i).first
pp release = Release.where(:id => track.release_id).first
pp album = Album.where(:id => release.album_id).first
pp artist = Artist.where(:id => album.artist_id).first
2011-04-08 19:42:14 +00:00
data = Vkontakte.get(artist.name, track.name, (track.length / 1000).round)
url = URI.parse(data['url'])
nginx_url = '/proxy-stream/no-token/' << data['remixsid'] << '/' << '5' << '/' << url.host << url.path
#render :inline => nginx_url
headers['Content-Type'] = 'audio/mpeg'
headers['X-Accel-Redirect'] = nginx_url
render :nothing => true
end
end