diff --git a/app/controllers/import_controller.rb b/app/controllers/import_controller.rb index ca84e85..1854660 100644 --- a/app/controllers/import_controller.rb +++ b/app/controllers/import_controller.rb @@ -16,7 +16,7 @@ class ImportController < ApplicationController begin lastfm_artist = lastfm.artist.get_info(name) - unless artist.mbid.nil? + unless artist.mbid.nil? or artist.mbid.empty? brainz_artist = MusicBrainz::Artist.find(artist.mbid) else brainz_artist = MusicBrainz::Artist.find_by_name(name) diff --git a/lib/tasks/lastfm_import.rake b/lib/tasks/lastfm_import.rake index e29dc0c..98b71e1 100644 --- a/lib/tasks/lastfm_import.rake +++ b/lib/tasks/lastfm_import.rake @@ -3,7 +3,7 @@ namespace :lastfm 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] + ')') + puts artist[:name] + (artist[:mbid].empty? ? '' : ' (' + artist[:mbid] + ')') record = Artist.find_or_create_by_name(artist[:name]) record.mbid = artist[:mbid] record.save