Search fixes
This commit is contained in:
		
							parent
							
								
									49f1fba33a
								
							
						
					
					
						commit
						1d9f527f39
					
				@ -10,7 +10,7 @@ class ArtistController < ApplicationController
 | 
			
		||||
      pics << artist.pic_url unless artist.pic_url.nil?
 | 
			
		||||
      unless artist.albums.empty?
 | 
			
		||||
        artist.albums.each do |album|
 | 
			
		||||
          pics << album.pic_url unless album.pic_url.nil?
 | 
			
		||||
          pics << album.pic_url unless album.pic_url.nil? or album.pic_url.empty?
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      render :json => {status: 'loading', pics: pics}
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ class ImportController < ApplicationController
 | 
			
		||||
      artist_lastfm_xml = open(
 | 
			
		||||
        'http://ws.audioscrobbler.com/2.0/'+
 | 
			
		||||
        '?method=artist.getinfo&api_key='+ @@lastfm_api_key +
 | 
			
		||||
        '&artist='+ URI.escape(name).gsub(/\&/, '%26').gsub(/\?/, '%3F')
 | 
			
		||||
        '&artist='+ URI.escape(name).gsub(/amp;/, '').gsub(/\&/, '%26').gsub(/\?/, '%3F')
 | 
			
		||||
      ).read
 | 
			
		||||
      artist_desc = artist_lastfm_xml.scan(/<summary><\!\[CDATA\[?(.*)\]\]><\/summary>/m)[0][0]
 | 
			
		||||
      artist_pic = artist_lastfm_xml.scan(/<image\ssize=\"extralarge\">?(.*)<\/image>/)[0][0]
 | 
			
		||||
@ -61,7 +61,7 @@ class ImportController < ApplicationController
 | 
			
		||||
          'http://musicbrainz.org/ws/2/release/'+ main_release[0] +'/?inc=recordings',
 | 
			
		||||
          'User-Agent' => @@user_agent
 | 
			
		||||
        ).read
 | 
			
		||||
        mb_tracks = main_tracks_mb_xml.scan(/<track>.*?<position>(\d+?)<\/position><recording\sid=\"([a-f0-9-]+?)\"><title>(.*?)<\/title><length>(.*?)<\/length>/m)
 | 
			
		||||
        mb_tracks = main_tracks_mb_xml.scan(/<track>.*?<position>(\d+?)<\/position>.*?<recording\sid=\"([a-f0-9-]+?)\"><title>(.*?)<\/title>(<length>(.*?)<\/length>)?/m)
 | 
			
		||||
        mb_tracks.map! do |item|
 | 
			
		||||
          item << main_release[3]
 | 
			
		||||
        end
 | 
			
		||||
@ -73,8 +73,8 @@ class ImportController < ApplicationController
 | 
			
		||||
            album_lastm_xml = open(
 | 
			
		||||
              'http://ws.audioscrobbler.com/2.0/'+
 | 
			
		||||
              '?method=album.getinfo&api_key='+ @@lastfm_api_key +
 | 
			
		||||
              '&artist='+ URI.escape(name).gsub(/\&/, '%26').gsub(/\?/, '%3F')+
 | 
			
		||||
              '&album='+ URI.escape(mb_album[2]).gsub(/\&/, '%26').gsub(/\?/, '%3F')
 | 
			
		||||
              '&artist='+ URI.escape(name).gsub(/amp;/, '').gsub(/\&/, '%26').gsub(/\?/, '%3F')+
 | 
			
		||||
              '&album='+ URI.escape(mb_album[2]).gsub(/amp;/, '').gsub(/\&/, '%26').gsub(/\?/, '%3F')
 | 
			
		||||
            ).read
 | 
			
		||||
            album_image = album_lastm_xml.scan(/<image\ssize=\"extralarge\">?(.*)<\/image>/)[0][0]
 | 
			
		||||
          rescue
 | 
			
		||||
@ -105,7 +105,7 @@ class ImportController < ApplicationController
 | 
			
		||||
              'http://musicbrainz.org/ws/2/release/'+ mb_release[0] +'/?inc=recordings',
 | 
			
		||||
              'User-Agent' => @@user_agent
 | 
			
		||||
            ).read
 | 
			
		||||
            mb_other_tracks = other_tracks_mb_xml.scan(/<track>.*?<position>(\d+?)<\/position><recording\sid=\"([a-f0-9-]+?)\"><title>(.*?)<\/title><length>(.*?)<\/length>/m)
 | 
			
		||||
            mb_other_tracks = other_tracks_mb_xml.scan(/<track>.*?<position>(\d+?)<\/position>.*?<recording\sid=\"([a-f0-9-]+?)\"><title>(.*?)<\/title><length>(.*?)<\/length>/m)
 | 
			
		||||
            mb_other_tracks.each do |item|
 | 
			
		||||
              unless mb_main_tracks_hashed.include? item[2].downcase.scan(/[a-z0-9]*/).join
 | 
			
		||||
                item << mb_release[3] # Release country
 | 
			
		||||
@ -122,9 +122,9 @@ class ImportController < ApplicationController
 | 
			
		||||
              track.name = mb_track[2]
 | 
			
		||||
              track.album_id = album.id
 | 
			
		||||
              track.position = mb_track[0]
 | 
			
		||||
              track.length = mb_track[3]
 | 
			
		||||
              track.country = mb_track[4]
 | 
			
		||||
              track.bonus = mb_track[5]
 | 
			
		||||
              track.length = mb_track[4]
 | 
			
		||||
              track.country = mb_track[5]
 | 
			
		||||
              track.bonus = mb_track[6]
 | 
			
		||||
              track.live = mb_track[2].downcase.include? 'live'
 | 
			
		||||
              track.acoustic = mb_track[2].downcase.include? 'acoustic'
 | 
			
		||||
              track.save
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@ require 'open-uri'
 | 
			
		||||
namespace :db do
 | 
			
		||||
  desc 'Imports test data from MusicBrainz database'
 | 
			
		||||
  task :import => :environment do
 | 
			
		||||
    ati = ['KISS']
 | 
			
		||||
    ati = ['The Killers']
 | 
			
		||||
    ati.each do |name|
 | 
			
		||||
      ImportController.importArtist(name)
 | 
			
		||||
      #ap res = ArtistController.musicBrainzExactSearch(name)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
var Search = {
 | 
			
		||||
	
 | 
			
		||||
	pics: [],
 | 
			
		||||
	
 | 
			
		||||
	showSpinner: function() {
 | 
			
		||||
		$('#search-container input').attr('disabled', 'disabled').blur();
 | 
			
		||||
		$('#search-container img').show();
 | 
			
		||||
@ -31,13 +33,15 @@ var Search = {
 | 
			
		||||
	
 | 
			
		||||
	showArtistPics: function(pics) {
 | 
			
		||||
		$('.artist_loading, .artist_pics').show();
 | 
			
		||||
		$('.artist_pics').html('');
 | 
			
		||||
		for (var i = 0; i < pics.length; i++) {
 | 
			
		||||
			$('.artist_pics').append('\
 | 
			
		||||
				<div class="pic">\
 | 
			
		||||
					<img src="'+ pics[i] +'" alt=""/>\
 | 
			
		||||
				</div>\
 | 
			
		||||
			');
 | 
			
		||||
		for (var i = 0; i < pics.length; i++) {console.log(Search.pics.indexOf(pics[i]));
 | 
			
		||||
			if (Search.pics.indexOf(pics[i]) === -1) {
 | 
			
		||||
				Search.pics.push(pics[i]);
 | 
			
		||||
				$('.artist_pics').append('\
 | 
			
		||||
					<div class="pic">\
 | 
			
		||||
						<img src="'+ pics[i] +'" alt=""/>\
 | 
			
		||||
					</div>\
 | 
			
		||||
				');
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ function authInfo(response) {
 | 
			
		||||
$(function(){
 | 
			
		||||
	VK.init({
 | 
			
		||||
		apiId: (document.location.host == 'beathaven.org' ? 2335068 : 2383163),
 | 
			
		||||
		nameTransportPath: "/demo/xd_receiver.html"
 | 
			
		||||
		nameTransportPath: "/xd_receiver.html"
 | 
			
		||||
	});
 | 
			
		||||
	VK.Auth.getLoginStatus(authInfo);
 | 
			
		||||
	$('#vk_login').click(function(){
 | 
			
		||||
@ -38,7 +38,8 @@ $(function(){
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
function loadTracksData(artist, track, duration, callback) {
 | 
			
		||||
	VK.Api.call('audio.search', {q: artist +' '+ track}, function(r){
 | 
			
		||||
	track_prepared = track.replace(/\(.*\)/i, '');
 | 
			
		||||
	VK.Api.call('audio.search', {q: artist +' '+ track_prepared}, function(r){
 | 
			
		||||
		callback(matchPerfectResult(r.response, artist, track, duration));
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user