Created
February 13, 2009 09:41
-
-
Save rdamen/63820 to your computer and use it in GitHub Desktop.
confreaks downloader
This file contains 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 '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