Skip to content

Instantly share code, notes, and snippets.

@yeban
Created March 6, 2012 10:59
Show Gist options
  • Select an option

  • Save yeban/1985683 to your computer and use it in GitHub Desktop.

Select an option

Save yeban/1985683 to your computer and use it in GitHub Desktop.
Download video lectures from NPTEL.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# FEM
page = "http://nptel.iitm.ac.in/video.php?subjectId=112106135"
download = "http://npteldownloads.iitm.ac.in/softlinks_mp4/112106135/lec%02d.mp4"
# load page
proxy = ENV["http_proxy"]
doc = Nokogiri(open(page, :proxy => proxy))
# parse lecture titles
titles = doc.search("a").select{|a| a.attr(:name) == 'lectureList'}.map(&:text).map(&:strip)
# download
(1..(titles.length)).each do |i|
%x|wget -c '#{download % i}' -O '#{titles[i - 1]}.mp4'|
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment