Skip to content

Instantly share code, notes, and snippets.

@christiangenco
Forked from csabapalfi/videos.js
Created March 28, 2012 11:24
Show Gist options
  • Select an option

  • Save christiangenco/2225519 to your computer and use it in GitHub Desktop.

Select an option

Save christiangenco/2225519 to your computer and use it in GitHub Desktop.
Download and Organize Coursera videos
$("h3.list_header").each(function(sectionIndex){
var sectionName = $(this).text().replace(/Chapter .+ - /,"").replace(/\:/,'-').replace(/^(V|I|X)+\. /,'');
$(this).parent().next().find("a.lecture-link").each(function(videoIndex){
var $lectureLink = $(this);
var videoName = $.trim($lectureLink.text());
var downloadLink = $lectureLink.attr('href').replace('view','download.mp4');
var cookieHeader = ' --header \"Cookie:'+ document.cookie + '\" ';
var directory = (sectionIndex+1) + '. ' + sectionName + '/';
var filename = directory + (videoIndex+1) + '. ' + videoName + '.mp4';
var cmd = 'echo "' + filename + '" && ';
cmd += 'mkdir -p "' + directory + '" && ';
cmd += 'curl -L -C - ' + cookieHeader + downloadLink + ' -o "' + filename + '"';
console.log(cmd);
});
}); null
@cnh

cnh commented Jun 1, 2012 via email

Copy link
Copy Markdown

@christiangenco

Copy link
Copy Markdown
Author

Creepy o_O

Not back in the US yet, unfortunately. Currently enjoying a holiday to Sydney :D

@cnh

cnh commented Jun 1, 2012 via email

Copy link
Copy Markdown

@christiangenco

christiangenco commented Jun 5, 2012 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment