Coursera-dl – A Script To Download Coursera Videos
Coursera is one of the popular and largest online educational platform on the planet. 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, I have got a good news. 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:
- 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.
- Using names from the syllabus page provides more informative names.
- Using wget in a for loop picks up extra videos which are not posted/linked, and these are sometimes duplicates.
- 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 Coursera-dl developer has created it. It makes the downloading process quite easier and faster. To put this simply, Coursera will obtain week and class names from the lectures page, and then download the related materials into appropriately named files and directories.
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 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 like below.
$ trizen -S coursera-dl
$ packer -S coursera-dl
$ yay -S coursera-dl
$ yaourt -S coursera-dl
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
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
And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!