Skip to content

Instantly share code, notes, and snippets.

@nikushi
Created April 8, 2012 16:43
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 nikushi/2338391 to your computer and use it in GitHub Desktop.
Save nikushi/2338391 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Dump subtitle in text for TED
#
require 'json'
require 'open-uri'
base_url = 'http://www.ted.com/talks/subtitles'
id = 1183
url = "#{base_url}/id/#{id.to_s}/lang/eng"
data = JSON.parse(open(url).read)
if data && data.key?('captions')
data['captions'].each do |sentence|
puts sentence['content']
puts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment