1
0
Fork 0

Import minor fixes

This commit is contained in:
magnolia-fan 2011-06-21 02:11:44 +04:00
parent b69c9cdbe0
commit 78cc2d343c
1 changed files with 19 additions and 15 deletions

View File

@ -44,9 +44,9 @@ class ImportController < ApplicationController
releases_mb_data = releases_mb_xml.scan(/<release\sid=\"([a-f0-9-]+?)\">.*?<status>([a-zA-Z]+?)<\/status>.*?<date>([0-9-]+?)<\/date>.*?<country>([A-Z]+?)<\/country>/m) releases_mb_data = releases_mb_xml.scan(/<release\sid=\"([a-f0-9-]+?)\">.*?<status>([a-zA-Z]+?)<\/status>.*?<date>([0-9-]+?)<\/date>.*?<country>([A-Z]+?)<\/country>/m)
releases_mb_data.each do |item| releases_mb_data.each do |item|
if item[2].length == 4 if item[2].length == 4
item[2] += '-01-01' item[2] += '-12-28'
elsif item[2].length == 7 elsif item[2].length == 7
item[2] += '-01' item[2] += '-28'
end end
end end
@ -92,10 +92,12 @@ class ImportController < ApplicationController
# Creating hashed array for matching # Creating hashed array for matching
mb_main_tracks_hashed = [] mb_main_tracks_hashed = []
mb_tracks.each do |mb_track| mb_tracks.each do |mb_track|
unless mb_main_tracks_hashed.include? mb_track[2].downcase.scan(/[a-z0-9]*/).join
mb_main_tracks_hashed << mb_track[2].downcase.scan(/[a-z0-9]*/).join mb_main_tracks_hashed << mb_track[2].downcase.scan(/[a-z0-9]*/).join
mb_track << main_release[3] # Release country mb_track << main_release[3] # Release country
mb_track << 0 # Bonus flag mb_track << 0 # Bonus flag
end end
end
# Searching for tracks in other releases # Searching for tracks in other releases
releases_mb_data.each do |mb_release| releases_mb_data.each do |mb_release|
@ -115,6 +117,7 @@ class ImportController < ApplicationController
# Saving tracks # Saving tracks
mb_tracks.each do |mb_track| mb_tracks.each do |mb_track|
unless mb_track[2] == '[silence]' or mb_track[2] == '[untitled]'
track = Track.new track = Track.new
track.name = mb_track[2] track.name = mb_track[2]
track.album_id = album.id track.album_id = album.id
@ -126,6 +129,7 @@ class ImportController < ApplicationController
track.acoustic = mb_track[2].downcase.include? 'acoustic' track.acoustic = mb_track[2].downcase.include? 'acoustic'
track.save track.save
end end
end
end # unless mb_main_tracks.empty? end # unless mb_main_tracks.empty?