Final changes before branching

This commit is contained in:
magnolia-fan
2011-06-13 16:16:22 +04:00
parent 3bb393bbc7
commit 1606ef8c0e
3 changed files with 14 additions and 11 deletions
+5 -1
View File
@@ -1,13 +1,17 @@
class TrackController < ApplicationController
require 'net/http'
require 'uri'
@@token_salt = '8FW*W#dWOH*FHW4j:Q@RQ{Qo[qF;fw0`0w4fkl'
def listen
pp track = Track.where(:id => params[:id].to_i).first
data = Vkontakte.get(track.artist_name, track.name, (track.length / 1000).round)
# data = Vkontakte.get(1, 1, 1)
url = URI.parse(data['url'])
nginx_url = '/proxy-stream/no-token/' << data['remixsid'] << '/' << '5' << '/' << url.host << url.path
token = Digest::SHA256.hexdigest(params[:id] << @@token_salt)
nginx_url = '/proxy-stream/' << token << '/' << data['remixsid'] << '/' << '5' << '/' << url.host << url.path
headers['Content-Type'] = 'audio/mpeg'
headers['X-Accel-Redirect'] = nginx_url