Lastfm import task fix
This commit is contained in:
parent
6c42b98383
commit
e94fae6099
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue