Home Command line utilities Coursera-dl – A Script To Download Coursera Videos

Coursera-dl – A Script To Download Coursera Videos

By sk
Published: Last Updated on 4.1K views

Coursera is one of the popular and largest online educational platform. It has partnered with various Universities, educational institutions and other organizations to offer online courses, specializations and degrees in numerous subjects, including engineering, humanities, medicine, biology, social sciences, mathematics, business, computer science, digital marketing, data science, and a lot more. As of October 2017, Coursera is offering more than 2,000 online courses and more than 28 million users have signed up with Coursera for its programs. If you're one of Coursera user, here is a good news for you! Now you can Download Coursera videos using a simple script from Command line in Linux.

Say hello to "Coursera-dl", a Python script that can be used to download lecture resources (e.g., videos, ppt, etc) for Coursera classes. Of course, you can use many downloader programs such as Youtube-dl, You-Get, Wget etc., to download the videos and other course materials. But the problem is those programs have the following limitations in general:

  1. Video names have numbers in them, but this does not correspond to the actual order. So, you may need to manually rename the videos one by one. It is time-consuming and bit difficult to find the videos in correct order.
  2. Using names from the syllabus page provides more informative names.
  3. Using wget in a for loop picks up extra videos which are not posted/linked, and these are sometimes duplicates.
  4. You can not download multiple courses at once, quizzes/homeworks, and links to extra material like 3rd party sites, papers, etc.

To address these problems, the developer of Coursera-dl has created it. It makes the downloading process quite easier and faster. To put this simply, Coursera-dl will obtain week and class names from the lectures page, and then download the related materials into appropriately named files and directories.

Installing Coursera-dl

Coursera-dl should work on any operating system that supports Python 2.x or 3.x. The officially recommended version is Python 3.4 or later.

You can install Coursera-dl script using Pip. If you haven't installed PIP yet, refer the following link.

Once PIP is installed, run the following command to install Coursera-dl script.

$ pip install coursera-dl

Python 3 users, use the below command:

$ pip3 install coursera-dl

I strongly recommend you to install it in virtual environments to avoid the python applications conflict with one another. For more details about Virtual environments, refer the "Creating Virtual Environments" section in the above link.

If you're on Arch Linux and its variants like Antergos, Manjaro Linux, Coursera-dl is available in AUR. You can install it using any AUR helper programs, for example Yay:

$ yay -S coursera-dl


Please note that you must enroll in Coursera before downloading the stuffs. Coursera-dl script is meant to be used only for your material that Coursera gives you access to download. Neither me nor the developer of this script is responsible for any violations of Coursera Terms Of Use.

Download Coursera Videos

Downloading Coursera materials using Coursera-dl script is fairly simple.

All you have to do is just run the following command from your Terminal:

$ coursera-dl -u <username> -p <password> modelthinking-004

Replace the username, password and course name with your own. If your password contains punctuation or any other special characters like  <, >, #, &, | etc., specify the password within a single quotes.

If you want to multiple courses, you can specify them with space-separated as shown below.

$ coursera-dl -u <username> -p <password> saas historyofrock1-001 algo-2012-002

You can also filter and download the videos by section name lecture name etc.

Say for example, to filter by section name, do:

$ coursera-dl -u <username> -p <password> -sf "Chapter_Four" crypto-004

Filter by lecture name:

$ coursera-dl -u <username> -p <password> -lf "3.1_" ml-2012-002

Sometimes you just want to download a specific course materials. Say for example, to download only PPT files in a course, run:

$ coursera-dl -u <username> -p <password> -f "ppt" qcomp-2012-001

Resume downloads

By default, you can terminate the download process by hitting the CTRL+C button. This will delete all partially downloaded materials, so you have to start the download process from the beginning. Sometimes, the download process might be interrupted by accidental power off, sudden system crash etc. If your download was interrupted by something other than KeyboardInterrupt (CTRL+C), the partially downloaded files will remain on your disk. In such cases, you can resume the download process from where you left it using --resume flag.

$ coursera-dl -u <username> -p <password> --resume sdn1-001

Add username/password in .netrc file to avoid repeated typing

If you don't want to type username and password every time, just add them in ~/.netrc file. If this file is not exist, just create it.

$ vi ~/.netrc

Add your username/password in the following format:

machine coursera-dl login <user> password <pass>

Now you can download the course materials without having to mention the username/password like below.

$ coursera-dl -n -- matrix-001

Some times, you want to preview the classes before downloading the full course materials. If so, you may need to use the following command:

$ coursera-dl -n -b ni-001

By default, the course materials will be downloaded in the current working directory. You can specify any location of your choice like below.

$ coursera-dl -n --path=/home/sk/Coursera/Classes/ comnetworks-002

Just make the given path is existed in your system.

For more options and usage details, refer the help section by running the following command:

$ coursera-dl --help


Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like


Matt April 13, 2020 - 6:18 am

I am having issues, and I wonder if I could receive help.

I have followed the instructions, but after I use “$ coursera-dl -u -p ” command (of course with my email and course name), I get this error:
raise AuthenticationFailed(‘Cannot login on coursera.org: %s’ % e)
coursera.cookies.AuthenticationFailed: Cannot login on coursera.org: 400 Client Error: Bad Request for url: https://api.coursera.org/api/login/v3

Am I doing something wrong?

sk April 13, 2020 - 11:03 am

Have a look at this thread. https://github.com/coursera-dl/coursera-dl/issues/702

If it still didn’t help, please file a new issue in the official GitHub repository.


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More