Last.fm mega import tasks

This commit is contained in:
magnolia-fan
2011-09-16 04:21:07 +04:00
parent e2b0fac59e
commit 9ec01e1d6c
6 changed files with 54 additions and 4 deletions
+22
View File
@@ -0,0 +1,22 @@
namespace :lastfm do
namespace :import do
desc 'Import top 1000 artists from last.fm'
task :top => :environment do
ImportController.parseLastfmXML('tmp/data/top1000.xml').each do |artist|
puts artist[:name] + (artist[:mbid].nil? ? '' : ' (' + artist[:mbid] + ')')
record = Artist.find_or_create_by_name(artist[:name])
record.mbid = artist[:mbid]
record.save
res = ImportController.importArtist(artist[:name])
if res == 1
puts 'OK'
elsif res == 2
puts 'FAIL'
elsif res == 3
puts 'SKIP'
end
puts ''
end
end
end
end