Coursera Bulk Download
javascript:(function(){
var cookies = ' --header \"Cookie:'+ document.cookie + '\" ';
var course = $('div#course-logo-text > a > img').attr('alt');
var START_UNIT=1;
console.log('#!/bin/bash');
$('a.list_header_link').each(function (index){
var num_unit = index + 1;
if (num_unit >= START_UNIT) {
var name_unit = $(this).children('h3').text().trim();
console.log('mkdir ' + '\"' + num_unit + '.' + name_unit + '\"');
console.log('cd ' + '\"' + num_unit + '.' + name_unit + '\"');
$(this).next('ul.item_section_list').children('li').children('a.lecture-link').each(function (index) {
var num_lecture = index + 1;
var name_lecture = num_unit + '.' + num_lecture + '.' + $(this).text().trim();
console.log('echo \"=== Downloading ' + course + "/" + name_unit + "/" + name_lecture + '\"');
$(this).next('div.item_resource').children('a').each(function(index) {
if (/\.mp4/.test($(this).attr('href'))) {
console.log('curl -L' + cookies + '\"' + $(this).attr('href') + '\"' + ' > ' +
'\"' + name_lecture + '.mp4\"');
} else if (/\.pptx/.test($(this).attr('href'))) {
console.log('curl -L' + cookies + '\"' + $(this).attr('href') + '\"' + ' > ' +
'\"' + name_lecture + '.pptx\"');
} else if (/subtitles.*txt/.test($(this).attr('href'))) {
console.log('curl -L' + cookies + '\"' + $(this).attr('href').replace('&format=txt', '') + '\"' + ' > ' +
'\"' + name_lecture + '.srt\"');
} else if (/\.pdf/.test($(this).attr('href'))) {
console.log('curl -L' + cookies + '\"' + $(this).attr('href') + '\"' + ' > ' +
'\"' + name_lecture + '.pdf\"');
}
});
});
console.log('cd ..');
}
});
})();