Skip to content

Instantly share code, notes, and snippets.

@tejo
Created August 23, 2009 10:30
Show Gist options
  • Select an option

  • Save tejo/173226 to your computer and use it in GitHub Desktop.

Select an option

Save tejo/173226 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'couchrest'
require 'freedb_reader'
require 'json'
@db = CouchRest.database!("http://127.0.0.1:5984/cd")
freedb_path = 'freedb-complete-20090801.tar/'
# freedb_path = 'freedb-update-20080501-20080601/'
dirs = Dir.entries(freedb_path).delete_if{|x| x.include?(".")}
dirs.each do |d|
Dir.entries(freedb_path+d).delete_if{|x| x.include?(".")}.each do |file|
entry = FreeDbReader.new(freedb_path+d+'/'+file)
begin
@db.bulk_save([
{"disc_id" => entry.disc_id,
"artist" => entry.artist,
"title" => entry.title,
"genre" => entry.genre,
"year" => entry.year,
"tracks" => entry.tracks}
])
rescue
end
puts "insert #{entry}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment