Skip to content

Instantly share code, notes, and snippets.

@yassermzh
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yassermzh/3c754b9916fdbb0df046 to your computer and use it in GitHub Desktop.
Save yassermzh/3c754b9916fdbb0df046 to your computer and use it in GitHub Desktop.
Download coursera videos from shell

Here is how I manage to download all videos of specific course from http://coursera.org. Even counrsera-downloader Chrome extension sucks. I would rather do it from command-line.

Requirements

  • nodejs
  • shelljs (npm install -g shelljs)

Instructions

  1. The following script to be run in 'all videos' page of http://coursera.org course, would copy all video links with their titles as JSON to clipboard.

    var videos = Array.prototype.slice.call(document.querySelectorAll('a[title="Video (MP4)"]'),0);
    var out = vidoes.map(function(video) { 
            return {link:video.href, title: video.querySelector('div').innerHTML.replace(/ /g, '_') + '.mp4'};
    });
    copy(out);

    Then save the clipboard data as videos.json file.

  2. Export http://coursera.org cookies after logging in using cookietxt-export chrome extension.

  3. Download all videos in videos.json having the cookies in cookies.txt with the following script:

    require('shelljs/global');
    var videos = require('./videos.json');
    videos.forEach(function(video) {
        console.log('downloading ',video.link);
        exec('wget --load-cookies cookies.txt ' + video.link+' -O "' + video.title + '"');
    }); 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment