2011-09-21 06:40:04 +00:00
|
|
|
class Discogs
|
|
|
|
def self.artists
|
|
|
|
File.open('tmp/data/discogs_artists.xml') do |file|
|
|
|
|
Nokogiri::XML::Reader.from_io(file).each do |node|
|
|
|
|
if node.name == 'artist' and node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT
|
|
|
|
self.process_artist Nokogiri::XML(node.outer_xml).root
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.process_artist node
|
2011-09-21 18:59:39 +00:00
|
|
|
artist = Artist.new(
|
2011-09-21 06:40:04 +00:00
|
|
|
:name => (node.css('name').first.text),
|
2011-09-21 23:20:41 +00:00
|
|
|
:pic_url => (node.css('images > image[type="primary"]').first.attr('uri') unless node.css('images > image[type="primary"]').empty?),
|
2011-09-21 06:40:04 +00:00
|
|
|
:status => 1
|
2011-09-21 18:59:39 +00:00
|
|
|
)
|
|
|
|
artist.save
|
|
|
|
node.css('namevariations > name, aliases > name').each do |v|
|
|
|
|
ArtistAlias.new(
|
|
|
|
:artist_id => artist.id,
|
|
|
|
:name => v.text
|
|
|
|
).save
|
|
|
|
end
|
2011-09-21 06:40:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.releases
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.process_release
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|