This is a python CLI program made for downloading enrolled courses and lectures from https://codewithmosh.com with high quality including all exercises and pdfs needed. This program allows you to download full courses, sections and lectures with ease. This program requires a valid credentials (headers and cookies) of an enrolled user to work.
Note: This project is only valid for people who have a valid account Or if the courses are free and are not locked. The project has no malicious intents what so ever.
For a long time I watched Mosh's YouTube channel where he only shows a tiny part of the full course. This made me eager to buy his courses and I ended up subscribing to the monthly subscription plan. But then I wanted to download a lot of courses from the site so using my python skills I made cwm-downloader-old but that didn't seem clean and was kinda bulky. So, I rewrote it again and here it is.
Note Currently my subscription has ended and I can't test the app with all the courses available anymore. So, I would appreciate contributions a lot. Read more about contributions at the bottom.
- python 3
- pip
Head over to the releases page and download the python wheel or the .whl
file.
First navigate to the directory where you downloaded the wheel file and execute the following command.
pip install [whl-file]
Replace the [whl-file]
with the python wheel file you downloaded
Even though it isn't recommended, you can use the sdist(.tar.gz
) file to install the project.
And there you go, the program is installed. Go to the Edit credentials section to authenticate yourself and download the courses you paid for.
If for any reason the pre-built binary doesn't work or has an error when installing with pip, check out the Manual installation, may be that could help.
This project uses poetry for dependency management, building and generating a cli command. So to install poetry. run
python -m pip install poetry
Or go to the docs and install poetry using another way.
Clone the repo and move in to it
git clone https://github.com/bython17/cwm-downloader && cd cwm-downloader
NOTICE: If you are a windows user, you need to enable the Windows Long Path in order to install the dependencies. To enable Windows Long Path you can execute the following PowerShell script(Windows 10, Version 1607, and Later)
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
Learn more at Microsoft
To install all the dependencies run
python -m poetry install
or
poetry install
If you installed poetry globally.
Now all dependencies should be installed in a venv and you can issue the command without using python like cwm-downloader --help
after typing poetry shell
To build and install the project follow the steps below, but before doing anything, you need to have python in path. If you don't have python in path, then Check this out.
Navigate to the projects root directory for the last time and run
poetry build
Poetry will now generate a dist directory which contains a wheel file that is installable by pip so run
pip install dist/[.whl file]
Replace the [.whl file]
with the .whl
file that poetry has created for you in the dist directory from the project's root. Or you can install the .tar.gz
file that is in the same directory.
Note Make sure that you run this outside a child shell or while not in a venv just to be safe.
and Horay 😃 Now you can access the command from any where in your computer !
The app relies on a json file that contains the headers and cookies of a valid account that is enrolled in some sort of course or lecture. To get the valid cookies and headers follow these simple steps.
-
Get the cookies and headers as a cURL
- Go to your browser.
- Sign in with your valid account.
- Navigate to any lecture that you are enrolled in.
- Open the devtools of the browser.
- Go to the "Networks" tab
- Click on the filter "Doc"
- Right click on the first request
- Select the sub option "copy all as cURL" from the option copy
-
Go to https://www.scrapingbee.com/curl-converter/json/ and paste the cURL you copied on the space provided and copy the final json output to your clipboard.
-
Run the program with the
--edit-credentials
optioncwm-downloader --edit-credentials
-
When the editor opens with the credentials.json file, delete all the contents inside and paste the contents you copied from https://www.scrapingbee.com/curl-converter/json/.
Now you are ready to run and use the program! 😎
The app is a CLI, so you can use the --help
option to learn more about the commands. But here are the basics
Download all lectures
To do that just execute the command with the download sub command and give it the url. For example let's download part one of the brand new C++ course.
cwm-downloader download https://codewithmosh.com/courses/ultimate-c-plus-plus-part1/lectures/42187035
This should download all the sections and lectures of the course. and btw you can use any lecture URL that is found on that course.
Download only one lecture
To download a single lecture you can do this
cwm-downloader download https://codewithmosh.com/courses/ultimate-c-plus-plus-part1/lectures/42187035 --section 2 --lecture 1 --only
This will tell the downloader you want to download that specifiec lecture only and nothin after that. notice here we specified a section because we need sections to get the correct lecture. if no section is given it is going to default to the first one.
Download a course from a specific point on wards
To do that just specifiy the point you want to start and don't specifiy the --only
flag.
cwm-downloader download https://codewithmosh.com/courses/ultimate-c-plus-plus-part1/lectures/42187035 --section 2 --lecture 1
There are a few more commands to play around with just check em out using
cwm-downloader --help
And you can also see the help message for the download subcommand
cwm-downloader download --help
I have tried to document my code very well to make it easy to understand. I am not a pro python engineer by any means just a high school kid who loves to code. So I would greatly appreciate any comments and code reviews from the community and If you have a great feature in mind don't forget to hit that pull request 😁. Thanks