How to install and run coursera-dl on M1 Mac without errors?

When attempting to install and run coursera-dl, the whole process is laden with errors, and it has been exceedingly difficult to actually get it to work.

I suspect this is a difficulty any Mac user installing coursera-dl would encounter, but you can never be sure when using the M1 chip so I tagged that in my question.

I am looking for answers that concicesly, and most importantly, effectively get coursera-dl working in the command prompt on an M1 mac.

I spent about 4 hours figuring out this today, so I'm going to post my own answer, but if others have more insight and\or figured out an easier way to do it their answers are welcome as well.


Solution 1:

We need to make sure we have python 3.8 installed, installing python 3.9 results in an issue with coursera-dl. We need to download and install 3.8 even though it lacks native M1 support.

Then we need to install pip3 and make sure it's added to the path.

then run the command

pip3 install coursera-dl

After running this command, running coursera-dl results in an error.

The issue was that python 3.8 wasn't added to the $PATH. This is somewhat of a hack but running pip3 uninstall coursera-dl prompts the user whether they want to delete the coursera-dl files. We want to say no, but this gives us the path of our current python3 version(should be 3.8).

From there we want to add python 3 to the $PATH by running the command

export PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin/:$PATH"

From here, if python 3.8 is installed and added correctly, and coursera-dl is installed, running coursera-dl should return a bunch of stuff, not an error

Now if we try to log into coursera, we'll get an error. The issue is that you need to feed coursera-dl a cookie CAUTH parameter. To find this weird value that validates your login, follow the instructions here: how to find CAUTH Value

The important instructions are:

How to find your Coursera CAUTH token by using your browser?
1 First login to coursera.org in your web browser :
2 For example, in chrome, Go to settings
3 Advanced
4 Privacy and Security
5 Site Settings
6 Cookies and Site Data
7 See all cookies and site data
8 coursera.org -> CAUTH
9 Copy this value. It might be kinda big

Now that we have the CAUTH token, we're ready to use coursera-dl

When we call coursera-dl, we need to make sure to use the -ca parameter and input our CAUTH token!

An example would be like this(this call worked for me)

coursera-dl -u yourUsername -p yourPassword -ca yourCauthToken className

It's important to realize that cookies expire, and so do CAUTH tokens. If your CAUTH token expires, simply do this last call with your newest CAUTH token as the parameter. Ie find it again and call coursera-dl with the newest value.