2011-09-16 00:21:07 +00:00
|
|
|
namespace :lastfm do
|
|
|
|
namespace :import do
|
|
|
|
desc 'Import top 1000 artists from last.fm'
|
|
|
|
task :top => :environment do
|
2011-09-26 05:10:23 +00:00
|
|
|
ActiveRecord::Base.logger = Logger.new('/dev/null')
|
2011-09-16 00:21:07 +00:00
|
|
|
ImportController.parseLastfmXML('tmp/data/top1000.xml').each do |artist|
|
2011-09-16 02:02:39 +00:00
|
|
|
puts artist[:name] + (artist[:mbid].empty? ? '' : ' (' + artist[:mbid] + ')')
|
2011-09-16 00:21:07 +00:00
|
|
|
record = Artist.find_or_create_by_name(artist[:name])
|
2011-09-20 20:30:42 +00:00
|
|
|
# record.mbid = artist[:mbid]
|
2011-09-16 00:21:07 +00:00
|
|
|
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
|
2011-09-18 14:25:47 +00:00
|
|
|
task :hyped => :environment do
|
2011-09-26 05:10:23 +00:00
|
|
|
ActiveRecord::Base.logger = Logger.new('/dev/null')
|
2011-09-18 14:25:47 +00:00
|
|
|
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])
|
2011-09-20 20:30:42 +00:00
|
|
|
# record.mbid = artist[:mbid]
|
2011-09-18 14:25:47 +00:00
|
|
|
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
|
2011-09-16 00:21:07 +00:00
|
|
|
end
|
|
|
|
end
|