Well, that was easy.
#!/usr/bin/ruby require "rubygems" require "mongo" require "json/pure" require "open-uri" db = Mongo::Connection.new.db('citeulike') col = db.collection('articles') j = JSON.parse(open("http://www.citeulike.org/json/user/neils").read) j.each do |article| article[:_id] = article['article_id'] col.save(article) end
Just to note (for others) that this isn’t really a proper backup as there isn’t a way to get the data back into CiteULike. A much better way would be to simply download the BibTeX. This has many advantages, especially that it can be used to restore your library (though not PDFs). SyncUThink (q.v.) is a good way to backup your PDFs.
Right, backup is not the correct term: perhaps “partial record of your library” would be better. I think it’s a fun and useful “quick hack”.