Railscasts downloader script

run it to download all railscasts, re-run it to update with newly released ones. Just run it in the folder where you want to keep them. yes, I could have used the word run a couple more times.
#!/usr/bin/ruby
require 'rss'

p 'Downloading rss index'

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('*.mov')
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
  p filename
  p %x(wget #{video_url} -O #{filename}.tmp )
  p %x(mv #{filename}.tmp #{filename} )
end
p 'Finished synchronization'
it's on github

Posted by Maximiliano Guzman Tue, 26 May 2009 16:23:00 GMT


Trackbacks

Use the following link to trackback from your own site:
http://maximilianoguzman.com.ar/trackbacks?article_id=5

Comments

Leave a response

  1. Avatar
    Aldo Escudero about 11 hours later:

    Thanks, for the info. I have been looking this for quite long.

  2. Avatar
    Alan Andrade 6 days later:

    Thank you very Much!!! I was trying to doing the job with wget, but I guess is enough. Cheers!!

  3. Avatar
    Bruno Antunes about 1 month later:

    Thanks for the script!

  4. Avatar
    Pedro Coelho 2 months later:

    Awesome! Very useful script!

  5. Avatar
    Michal Papis 7 months later:

    I know that writing ruby scripts is important for gathering knowledge, but I have shorter solution http://niczsoft.com/2010/01/download-all-railscasts/ using wget :)

  6. Avatar
    Scorpio about 1 year later:

    I figured out a much quicker way to do this.

    if you’re using Firefox install the Flashgot addon

    Go to http://feeds.feedburner.com/railscasts Right click and select Flashgot all than pick the files / filetypes you want (there should be a checkbox for it say .mov (200) 300) or how many episodes there were and just click Ok and proceed like with any other download.

    Hope it helps

    PS should work with any equivalent software

Leave a comment