Metadata-Version: 2.4
Name: dl_coursera
Version: 1.1.0
Summary: A simple, fast, and reliable Coursera crawling & downloading tool
Author-email: fengleizZZ <fenglei4518@hotmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/FLZ101/dl_coursera
Project-URL: Repository, https://github.com/FLZ101/dl_coursera
Project-URL: Issues, https://github.com/FLZ101/dl_coursera/issues
Project-URL: Changelog, https://github.com/FLZ101/dl_coursera/blob/master/CHANGELOG.md
Keywords: dl_coursera,coursera,education,MOOC
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Education
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: beautifulsoup4>=4.13.4
Requires-Dist: Jinja2>=3.1.6
Requires-Dist: lxml>=6.0.0
Requires-Dist: requests>=2.32.4
Requires-Dist: tqdm>=4.67.1
Provides-Extra: dev
Requires-Dist: pre-commit>=3.7.0; extra == "dev"
Requires-Dist: black>=24.8.0; extra == "dev"
Provides-Extra: deploy
Requires-Dist: build; extra == "deploy"
Requires-Dist: cryptography>=42.0.0; extra == "deploy"
Requires-Dist: Nuitka; extra == "deploy"
Requires-Dist: setuptools; extra == "deploy"
Requires-Dist: twine; extra == "deploy"
Requires-Dist: wheel; extra == "deploy"
Dynamic: license-file

[![](https://img.shields.io/pypi/v/dl_coursera)](https://pypi.org/project/dl-coursera/)[![](https://github.com/FLZ101/dl_coursera/actions/workflows/test-single.yml/badge.svg)](https://github.com/FLZ101/dl_coursera/actions/workflows/test-single.yml)[![](https://img.shields.io/github/license/FLZ101/dl_coursera)](https://github.com/FLZ101/dl_coursera/blob/master/LICENSE.txt)[![](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Todo

- [x] Lectures (videos, subtitles, slides)
- [x] Reading materials
- [ ] Jupyter notebooks
- [x] Quizzes

## Install

Python **⩾3.10** is required.

Install the `dl_coursera` package in a virtual environment.

```
$ pip install -U dl_coursera
$ dl_coursera --version
```

Alternatively, you can download `dl_coursera` as a single executable from [https://github.com/FLZ101/dl_coursera/releases/](https://github.com/FLZ101/dl_coursera/releases/). **Note**:

* This may not work if your OS is outdated
* On Windows, SmartScreen may prevent execution of the executable

## How-to

1. Get the cookies file

   Sign into [Coursera](https://www.coursera.org/), then use a browser extension to export cookies as a cookies file which will expire in about two weeks.

   For Chrome/Edge/Firefox, you can use the **Cookie-Editor** extension.

   ![](doc/cookies.png)

2. Enroll

   Navigate to homepage of the **specialization**/**course** you'd like to download, you can see its **slug** at the address bar. **Enroll** in.

   ![](doc/enroll.png)

3. Download

   To download a specialization:

   ```
   dl_coursera --cookies path_of_the_cookies_file --outdir output_directory --spec slug
   ```

   To download a course:

   ```
   dl_coursera --cookies path_of_the_cookies_file --outdir output_directory slug
   ```

   For each course, a `playlist.m3u` file is generated in the course directory. It lists the downloaded videos and can be opened with VLC, mpv, or mplayer.

   ---

   Extra options:

   * `--quiz`: include quizzes
   * `--subtitles <languages>`: comma-separated subtitle language codes without spaces, e.g. `en,zh-CN`. Typical codes: `en`, `zh-CN`, `es`, `fr`, `de`, `pt-BR`, `ja`, `ko`, `ru`, `it`, `ar`, `hi`. Default: download the only available language; otherwise English if available.

   ![](doc/run.png)

## Note

* If math symbols do not render or images do not show in downloaded HTML files, the browser may be opening them from a Flatpak sandbox path such as `file:///run/user/1000/doc/...`, which prevents loading the local `resource/` files. Open the files with a non-Flatpak browser, drag the directory containing `resource/` into the browser window, or make the output directory accessible to the Flatpak sandbox.

## Troubleshooting

1. Check your network

2. Make sure you have enrolled in the specialization/course

3. If the cookies file might have expired, try getting a new one

4. Try upgrading to the latest version

5. Remove the directory `<output-directory>/<slug>/.cache` and try again

6. Visit [the issues page](https://github.com/FLZ101/dl_coursera/issues?q=is:issue). You may find a solution if others has encountered similar issues.

   Or you could create a new issue describing what is going wrong and the steps to reproduce it. Don't forget to attach the file `<output-directory>/<slug>/.cache/main.log` if it exists.

## Star History

[![Star History Chart](https://api.star-history.com/chart?repos=flz101/dl_coursera&type=date&legend=top-left)](https://www.star-history.com/?repos=flz101%2Fdl_coursera&type=date&legend=top-left)
