Coursera to Google Drive (All materials downloaded, without internet cost)
Coursera is one of the best sources for online learning. It has some of the best MOOCs(Massive Open Online Courses) on some topics, in the whole internet. During recent COVID-19 pandemic, and global lockdown, the were generous enough to let students like us enroll and complete in any(or multiple) of the 3800+ courses(with certificate) just by registration with institution. I just cant thank them enough, for this contribution to society, spreading knowledge free of cost and helping to make this lockdown productive.
Now, the problem is arising, when everything is coming to an end. Coursera has announced that, the chance of enrolling for free we be ended at the end of September. So , a lot of us are cursing ourselves, that we didn’t utilize this amazing opportunity when we had time, and as everything is being over, if there was any way, to download some of these amazing educational resource, for learning later. We also should keep materials of the courses, that we have completed for revision, as knowledge does evaporate with time!😅
So, while digging I found a python package coursera-dl
that can help in this situation. But sadly , I couldn’t figure it out, and faced many errors. Then I came across an amazing Google Colab notebook(those who don’t know, don’t worry…we will check it out a few moments later) that utilized this package, but made the process ridiculously easy. I really don’t know who the author is, but would have really liked to mention him.
Those who are familiar with python and Colab notebooks, can access the notebook here. Those who are unfamiliar…don’t worry! Everything you need to know will be discussed here, so just open the notebook in another tab, and follow along the post!
Though all of this is created with python, but you don’t need to know python even a little bit. About Colab notebooks , you just have to know that, we run every there by pressing Shift + Enter.
In the notebook, we just need to perform three major tasks.
- Mounting your google drive
- Get Coursera CAUTH (authentication code)
- Download with the name of the course
Everything will be explained. No worries!!!
In the notebook, you have to run only the cells, that have codes(I have told above, how to run a cell) . First connect the notebook, by clicking connect at top left corner.
First run the cell..
pip install coursera-GDrive
Then wait until it’s completion, you will understand when it is complete.Then this cell.
from coursera_gdrive import CourseraDownloaderdownloader = CourseraDownloader()
This actually creates an instance of the CourseraDownloader class.But you don’t need to know that. Rather you need to know that now you will see a link and a box. Click the link, in another tab it will take you to select a gmail id, where you want to save the files. After selecting , you will give permission, and then get an authorization code. Copy the code, paste it to the box under the link, and hit enter. Boom, your drive is mounted! You can check the contents selecting an option from left vertical strip. But, lets stay on our track.
When it is complete, next step is Coursera authentication. It it a little messy process. It is better if you have Google Chrome for this step, beacause I will describe for Chrome.(You know, Google Colab, Google Drive…why not Google Chrome!!😛)
First login to Coursera with Chrome(Even if you are logged in , it is better to go to the site). Then go to settings, and from left strip, select Privacy and Security. Then you need too go to site settings.Its in last option under privacy settings. Now, scroll through the permissions tab. Under that you will find content, where the first option is Cookies and Site Data, click there. At the next page , at fifth or sixth option you will find See all cookies and site data. Clicking there, you will get a huge list of cookies, utilize the search box and search cousera.org.
When you get it , click there and you will find our golden goose, CAUTH. Find and copy the content in it. Now, come back to our beloved Notebook.
cauth = "<cauth-token>"downloader.login(cauth)
In this cell, replace the <cauth-token> part with the CAUTH content,. Remember not to remove the quotations wrapping the text, they will remain there(Any text in python is wrapped by quotations). Run the cell and now we are almost done.
Now you just need to get the course name and download it. You can play with printEnrolledCourses() , printAllCourses()
and setSubtitles()
methods in the notobook as instructed, but we will jump straight to the last cell.(Some function are called by the name ‘method’ in Object Oriented Programming, but you also don’t need to know that!)
To find the actual course name , you need to go to the homepage of a course, at Coursera website, and check the link. https://www.coursera.org/learn/<course-name>/home/welcome
The text in the <course-name> part, is you course name. Just copy that, and paste that at the last cell. Don’t forget to wrap it with quotes.
downloader.download("<course-name>")
Then you will see the download starting…You yourself will see the speed, but Colab Notebooks internally get 25–30 MBps speed, so you don’t have to wait for long.
So we are done, but I want to mention some answers of the questions , I got from my friends.
- No.You don’t need to repeat the full process for every course, once a notebook is connected, you can download as many courses you want(Just replace the course name, and run that cell). But If it is disconnected, you might have to repeat the full process.
- Yes.You can try to download a course that you are not enrolled to, but some materials might be missing. Depending on the course, You might even not get access to a course.
- As described in the notebook, you can download multiple courses at once. But sometimes I have found it not to work. Besides, as the courses are being saved in Google drive, it is easier to keep track of the storage if you download the courses one by one.
I don’t think its illegal. As the Terms of use of Coursera mention, ” You may download content from our Services only for your personal, non-commercial use, unless you obtain Coursera’s written permission to otherwise use the content” , Don’t use this process for any other purpose other than personal, non-commercial use. Don’t let yourself and anyone else end up in jail, or Coursera’s block list!😛
Goodbye for today. If you have any question or query, feel free to ask in comments. This notebook is neither my property nor my idea. I don’t know the author, but am very much grateful to him and his work.