Created
January 8, 2014 00:40
-
-
Save orendon/8309610 to your computer and use it in GitHub Desktop.
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' | |
subscriber_id = "41TjtXC14dnMq0aFyllyKw" | |
download_dir = "/srv/http/data.ineu.pp.ua/shared/public/system/railscasts" | |
url = "http://railscasts.com/subscriptions/#{subscriber_id}/episodes.rss" | |
feed = RSS::Parser.parse(url) | |
# only pro/revised episodes | |
urls = feed.items.map { |i| i.enclosure.url }.select {|url| url =~ /subscriptions/ } | |
Dir.chdir download_dir | |
local_ids = Dir['*'].map { |i| i.split('-').first } | |
remote_ids = urls.map { |url| File.basename url }.map { |i| i.split('-').first } | |
diff = remote_ids - local_ids | |
diff.each do |id| | |
url = urls.detect { |url| url.include? id } | |
`wget #{url}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment