Tons of fixes
This commit is contained in:
@@ -3,15 +3,15 @@ class ArtistController < ApplicationController
|
||||
require 'open-uri'
|
||||
def view
|
||||
# Dirty auth block START
|
||||
unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
|
||||
redirect_to '/login'
|
||||
return
|
||||
else
|
||||
if request.session['session_id'].nil?
|
||||
redirect_to '/login'
|
||||
return
|
||||
end
|
||||
end
|
||||
# unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
|
||||
# redirect_to '/login'
|
||||
# return
|
||||
# else
|
||||
# if request.session['session_id'].nil?
|
||||
# redirect_to '/login'
|
||||
# return
|
||||
# end
|
||||
# end
|
||||
# Dirty auth block END
|
||||
if params[:name].nil?
|
||||
name = ''
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
class MainController < ApplicationController
|
||||
def index
|
||||
# Dirty auth block START
|
||||
unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
|
||||
redirect_to '/login'
|
||||
else
|
||||
if request.session['session_id'].nil?
|
||||
redirect_to '/login'
|
||||
end
|
||||
end
|
||||
# Dirty auth block END
|
||||
end
|
||||
def self.logged_in session_id
|
||||
user_data = User.collection.find({session_key: Digest::SHA256.hexdigest(session_id)}).first
|
||||
unless user_data.nil?
|
||||
user_data['lastvisit'] = Time.now()
|
||||
User.collection.update({_id: user_data._id}, user_data.attributes)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
# unless User.logged_in
|
||||
# redirect_to '/login'
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -3,18 +3,14 @@ class TrackController < ApplicationController
|
||||
require 'uri'
|
||||
def listen
|
||||
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
|
||||
|
||||
data = Vkontakte.get(artist.name, track.name, (track.length / 1000).round)
|
||||
|
||||
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
|
||||
#render :inline => nginx_url
|
||||
|
||||
headers['Content-Type'] = 'audio/mpeg'
|
||||
headers['X-Accel-Redirect'] = nginx_url
|
||||
headers['Connection'] = 'close'
|
||||
render :nothing => true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user