-
-
Save gberger/5281081 to your computer and use it in GitHub Desktop.
Download Railscasts episodes on Windows!This will download all missing free Railscasts episodes onto the folder where the script is.If you are a Pro subscriber, you can just sub in your Pro RSS feed and have it download Pro episodes too.
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
require 'rss' | |
require 'open-uri' | |
p "Downloading rss index" | |
# If you are a Railscasts Pro subscriber, you will have a different RSS feed with Pro casts | |
# If this is the case, go to http://railscasts.com/, find it and sub it below | |
rss_string = open('http://feeds.feedburner.com/railscasts').read | |
rss = RSS::Parser.parse(rss_string, false) | |
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse | |
videos_filenames = videos_urls.map {|url| url.split('/').last } | |
existing_filenames = Dir.glob('*.mp4') | |
missing_filenames = videos_filenames - existing_filenames | |
p "Downloading #{missing_filenames.size} missing videos" | |
missing_videos_urls = videos_urls.select { |video_url| missing_filenames.any? { |filename| video_url.match filename } } | |
missing_videos_urls.each do |video_url| | |
filename = video_url.split('/').last | |
next if File.exists? filename | |
p "Downloading #{video_url}..." | |
File.open(filename, "wb") do |saved_file| | |
open(video_url, 'rb') do |read_file| | |
saved_file.write(read_file.read) | |
end | |
end | |
p "-> #Downloaded to #{filename}!" | |
end | |
p 'Finished synchronization' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment