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.
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
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
Va?
Hehe, du ?r rolig du Peter
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…