Skip to content

Instantly share code, notes, and snippets.

@danhigham
Created May 22, 2011 08:03
Show Gist options
  • Save danhigham/985271 to your computer and use it in GitHub Desktop.
Save danhigham/985271 to your computer and use it in GitHub Desktop.
Script to download all Scotland Ruby 2011 videos
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
dependencies = [:wget, :curl]
dependencies.each { |program| !`which #{program.to_s}`.empty? || STDERR.puts( "Requires #{program}") }
index_doc = Hpricot(open("http://confreaks.net/events/scotlandruby2011"))
video_links = (index_doc/".video .title a")
video_links.each do |a|
video_link = a.attributes['href']
video_url = "http://confreaks.net#{video_link}"
video_html = `curl #{video_url}` #this fails with a 500 when using open-uri, not sure why
video_doc = Hpricot(video_html)
assets = (video_doc/".assets .asset-box a")
video = assets[0].attributes['href']
`wget http://confreaks.net#{video}`
end
@kotp
Copy link

kotp commented May 22, 2011

dependencies = [:wget, :curl]
dependencies.each { |program| !`which #{program.to_s}`.empty? || STDERR.puts( "Requires #{program}") }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment