1
0
Fork 0
oldhaven/lib/discogs.rb

34 lines
874 B
Ruby
Raw Normal View History

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
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
)
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