1
0
Fork 0
oldhaven/lib/tasks/lastfm_import.rake

41 lines
1.3 KiB
Ruby

namespace :lastfm do
namespace :import do
desc 'Import top 1000 artists from last.fm'
task :top => :environment do
ActiveRecord::Base.logger = Logger.new('/dev/null')
ImportController.parseLastfmXML('tmp/data/top1000.xml').each do |artist|
puts artist[:name] + (artist[:mbid].empty? ? '' : ' (' + 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
task :hyped => :environment do
ActiveRecord::Base.logger = Logger.new('/dev/null')
ImportController.parseLastfmXML('tmp/data/hyped500.xml').each do |artist|
puts artist[:name] + (artist[:mbid].empty? ? '' : ' (' + 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