From 1606ef8c0e453b31832f28a22c1067e59f5de4ba Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Mon, 13 Jun 2011 16:16:22 +0400 Subject: [PATCH] Final changes before branching --- app/controllers/track_controller.rb | 6 +++++- config/vk_accounts.yml | 14 +++++++------- nginx/proxy.conf | 5 ++--- 3 files changed, 14 insertions(+), 11 deletions(-) mode change 100644 => 100755 nginx/proxy.conf diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 4d5b17f..fec5301 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -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 diff --git a/config/vk_accounts.yml b/config/vk_accounts.yml index fe3176b..b8373de 100644 --- a/config/vk_accounts.yml +++ b/config/vk_accounts.yml @@ -45,13 +45,13 @@ Paganini: # Tom_Orrow user_agent: "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16" # Stolen -Stolen_Moroz: - user_id: 9444259 - email: 89232979779@mail.ru - password: beatcobot1 - remixsid: d5b1289ae534887319f41bdebf435f9ed3721ccf9203d7 - remixchk: 5 - user_agent: "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16" +# Stolen_Moroz: +# user_id: 9444259 +# email: 89232979779@mail.ru +# password: beatcobot1 +# remixsid: d5b1289ae534887319f41bdebf435f9ed3721ccf9203d7 +# remixchk: 5 +# user_agent: "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16" Stolen_NarutoSasuke: user_id: 29280365 diff --git a/nginx/proxy.conf b/nginx/proxy.conf old mode 100644 new mode 100755 index 47949d8..4d8dedf --- a/nginx/proxy.conf +++ b/nginx/proxy.conf @@ -30,9 +30,8 @@ location ~* ^/proxy-stream/(.*?)/(.*?)/(.*?)/(.*?)/(.*) { # backend does not support Content-Disposition # headers used to specify file name browsers use # when save content to the disk - proxy_ignore_headers Cache-Control; - #add_header Content-Disposition 'attachment; filename=audio.mp3'; - #add_header Connection 'close'; + proxy_ignore_headers Cache-Control Expires; + # Do not touch local disks when proxying # content to clients