Import dry run

This commit is contained in:
magnolia-fan
2011-06-29 00:54:46 +04:00
parent 391288d861
commit 655e30f995
4 changed files with 9 additions and 10 deletions
+7 -5
View File
@@ -11,7 +11,7 @@ class ImportController < ApplicationController
@@brainz_login = 'magnolia_fan'
@@brainz_password = '111111'
def self.importArtist name
def self.importArtist name, dry_run = false
# Initializing gems
brainz = MusicBrainz::Client.new(@@brainz_login, @@brainz_password, @@user_agent)
@@ -52,7 +52,7 @@ class ImportController < ApplicationController
# Checking if there is already an album with the same name
albums_db = Album.where(:artist_id => artist.id, :name => album_name, :album_type => mb_album['type'])
# Get album releases from MB
releases_mb = brainz.release(nil, {'release-group' => mb_album['id']})
@@ -121,7 +121,8 @@ class ImportController < ApplicationController
album.mbid = mb_album['id']
album.album_type = mb_album['type']
album.pic_url = album_image
album.save
album.save unless dry_run
ap album if dry_run
# Creating hashed array for matching
mb_main_tracks_hashed = []
@@ -175,7 +176,7 @@ class ImportController < ApplicationController
track.live = mb_track['recording']['title'].downcase.include? 'live'
track.acoustic = mb_track['recording']['title'].downcase.include? 'acoustic'
track.mbid = mb_track['recording']['id']
track.save
track.save unless dry_run
end
end
@@ -199,7 +200,8 @@ class ImportController < ApplicationController
artist.status = 2
end
artist.save
artist.save unless dry_run
ap artist if dry_run
end # def self.importArtist name