Created
March 6, 2012 10:59
-
-
Save yeban/1985683 to your computer and use it in GitHub Desktop.
Download video lectures from NPTEL.
This file contains hidden or 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 '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