Created
February 13, 2013 16:23
-
-
Save mikbe/4945780 to your computer and use it in GitHub Desktop.
Download all Railscast Pro and regular episodes (if you have a subscription)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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