Lastfm import task fix
This commit is contained in:
		
							parent
							
								
									6c42b98383
								
							
						
					
					
						commit
						e94fae6099
					
				| @ -16,7 +16,7 @@ class ImportController < ApplicationController | |||||||
|      |      | ||||||
|     begin |     begin | ||||||
|       lastfm_artist = lastfm.artist.get_info(name) |       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) |         brainz_artist = MusicBrainz::Artist.find(artist.mbid) | ||||||
|       else |       else | ||||||
|         brainz_artist = MusicBrainz::Artist.find_by_name(name) |         brainz_artist = MusicBrainz::Artist.find_by_name(name) | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ namespace :lastfm do | |||||||
|     desc 'Import top 1000 artists from last.fm' |     desc 'Import top 1000 artists from last.fm' | ||||||
|     task :top => :environment do |     task :top => :environment do | ||||||
|       ImportController.parseLastfmXML('tmp/data/top1000.xml').each do |artist| |       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 = Artist.find_or_create_by_name(artist[:name]) | ||||||
|         record.mbid = artist[:mbid] |         record.mbid = artist[:mbid] | ||||||
|         record.save |         record.save | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user