codahale.com٭blog

Coda Hale lives in Berkeley, CA, where he writes about Ruby on Rails, usability, web design and development, and the occasional bit about bicycles.

GVP Download: A quick and dirty Ruby script to download Google Videos

So Google Video has a bunch of really awesome content, but watching it with Flash is a CPU-hogging, lowest-common-denominator experience. So here’s a quick script to go from video URL to watchable AVI:

#!/usr/bin/env ruby

require "open-uri"

puts "Downloading descriptor file..."
gvp_id = ARGV[0].gsub(/\D/, "")
gvp_doc = open("http://video.google.com/videogvp/gvp-download.gvp?docid=#{gvp_id}").read.split("\\n")

gvp_doc.find { |x| x =~ /^url:(.*)$/ }
gvp_movie_url = $1.gsub(/&/, '\\\\\\&').gsub(/\\?/, '\\\\\\?')

gvp_doc.find { |x| x =~ /^title:(.*)$/ }
gvp_title = $1

puts "Downloading \"#{gvp_title}\"..."
puts "wget -O #{(gvp_title + ".avi").inspect} #{gvp_movie_url}"

If you want to use curl instead of wget, change the last line of code.

This probably violates some terms of use, so this is only a intellectual demonstration of the wonderment and possibilitude of the programmablemated webernet.

BTW, it’s amazing how much I had to escape things to pass the right values through Wordpress, Ruby’s weird-ass string escaping, and finally Bash. Lots of backslashes.

9 comments »

Headed to RailsConf

Just a general ping: I’m headed to RailsConf on Wednesday.

I look like this:

Me

If I’ve had coffee, my eyes’ll be a bit wider, and I’ll be yelling things about rails-core and patches. If I’m sleepy, uh, I’ll squint and grumble. Here’s my day-time ticket.

So yeah, yell at me, or buy me a drink or something.

2 comments »

Dispelling rumours

Personally, I’m a TextMate kind of a guy.

4 comments »

How not to disagree with someone

This is appalling.

I’ve certainly taken jokes too far, poked fun at people, played dirty while arguing, thrown elbows, given low blows, picked low-hanging fruit, made ad hominem attacks, and gone there. But that? That’s broken. You don’t have to agree with Kathy Sierra — you don’t even have to like her — but by God you will treat her with the same respect you treat any other person in this world.

1 comment »

bcrypt-ruby 2.0.0 is out

Just a quick note, I just released bcrypt-ruby 2.0.0, featuring some refactored goodness.

http://bcrypt-ruby.rubyforge.org

2 comments »