Skip to content

Instantly share code, notes, and snippets.

@rdamen
Created February 13, 2009 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdamen/63820 to your computer and use it in GitHub Desktop.
Save rdamen/63820 to your computer and use it in GitHub Desktop.
confreaks downloader
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
PROGRAMS = '//td/em/a[1]'
FORMATS = '//ul[@class="formatlist"]/li/a'
PRIORITY = {"small" => 0, "normal" => 1, "large" => 2}
def doc(url)
Nokogiri.HTML(open(url).read)
end
def best_of(formats)
best = which = 0
formats.each_with_index do |format, index|
if format['href'] =~ /(\w+)\.mp4$/
if PRIORITY[$1] > best
best = PRIORITY[$1]
which = index
end
end
end
formats[which]
end
def leech conf
url = "http://#{conf}.confreaks.com/"
doc(url).xpath(PROGRAMS).each do |program|
formats = doc(url + program['href']).xpath(FORMATS)
`wget -c #{url}#{best_of(formats)['href']}`
end
end
ARGV.each {|conf| leech conf}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment