Download all files in RSS feed using Ruby

I’m working on learning Ruby on Rails and one great resource that I find myself going to is RailsCast. But as I really need to learn Ruby I wanted to write a quick program to download all the episodes to my harddisk and watch them using Plex Media Center. There’s probably a million different utilities (or podcast managers) that can do that, but using them I won’t learn to program Ruby that way. There’s probably a better way of doing this, but hey, do it and post a comment. [cc lang="ruby"] require ‘rubygems’ require ‘hpricot’ require ‘open-uri’

doc = Hpricot.XML(open(“http://feeds.feedburner.com/railscasts”))

(doc/”enclosure”).each do |para| filename = File.basename(para[:url]) puts “== Found a file #{filename}” open(filename,”w”).write(open(para[:url]).read) end [/cc]


Related posts:

  1. Ruby on Rails Beginners
  2. GTD, Ruby on Rails and the Mac
  3. I’m a lucky guy
  4. TextMate
  5. iPhone will increase Macintosh software

3 thoughts on “Download all files in RSS feed using Ruby

  1. Men skaffa f?r fan en gravatar. Tryck p? Gravatar bilden och regga dig. Det ?r ju hela din framst?llning p? n?tet som st?r p? spel…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>