Skip to content

Instantly share code, notes, and snippets.

@mikbe
Created February 13, 2013 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikbe/4945780 to your computer and use it in GitHub Desktop.
Save mikbe/4945780 to your computer and use it in GitHub Desktop.
Download all Railscast Pro and regular episodes (if you have a subscription)
#!/usr/bin/env ruby
require 'rss'
require 'open-uri'
require 'net/http'
# Your subscription ID
sub_id = "xxx"
url = "http://railscasts.com/subscriptions/#{sub_id}/episodes.rss"
puts "Reading RSS"
open(url) do |rss|
feed = RSS::Parser.parse(rss)
puts "Title: #{feed.channel.title}"
feed.items.each do |item|
puts "Item: #{item.title}"
url = item.enclosure.url
filename = File.basename(url)
if File.exists?(filename)
puts "Existing file: #{filename}"
else
puts "Downloading: #{filename}"
open(filename, 'wb') do |file|
file << open(url).read
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment