udemy-downloader

Puyodead1MIT活跃维护

用 Python 写的 Udemy 课程下载器,支持 DRM 加密视频,能把已购课程批量保存到本地离线观看。

A Udemy downloader that can download courses, with DRM support.

1.0发布于 2021-05-19 23:10 UTC2,094star +2 / 7 天433fork同步于 2026-11-10 23:46 UTC

怎么上手

由 README 提炼,执行前请确认
pip install yt-dlp
python -m udemy_downloader <Course URL> -b <Bearer Token>
硬件要求按 README 说明

README 未说明显存要求;NVENC 硬件转码需受支持的 NVIDIA GPU 及带 nvenc 支持的 ffmpeg,其余功能无特殊硬件要求

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

下载 Udemy 课程并支持 DRM 加密视频的 Python 工具,但需自备解密密钥

用 Python 写的 Udemy 课程下载器,支持 DRM 加密视频,能把已购课程批量保存到本地离线观看。

核心能力

  • 支持 DRM 加密课程,需在 keyfile.json 填入 Key ID 与密钥
  • 通过 Bearer Token 或从浏览器自动提取 cookies 认证
  • 可下载视频、字幕、附件与测验,支持指定画质与字幕语言
  • 用 aria2c 与 yt-dlp 分片并发下载,并发数可调 1-30
  • 可选 H.265 编码与 NVIDIA NVENC 硬件转码

容易踩的坑

ffmpeg、aria2c、yt-dlp 需手动单独安装并加入系统 PATH,pip 不会装;无解密密钥时加密课程无法下载;需先把 keyfile.example.json 改名为 keyfile.json 并填好密钥

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

1 个版本1.0
  1. 1.0Inital Release最新正式版2021-05-19 · 2021-05-19 23:10 UTC

    这个版本没有写更新说明。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Udemy Downloader with DRM support

    forthebadge forthebadge forthebadge forthebadge GitHub forks GitHub Repo stars GitHub

    [!IMPORTANT]
    At the moment I am not actively maintaining this project.

    I still merge PRs, fix minor bugs that are found, and handle minor issues but otherwise, this project relies on pull requests.

    NOTE

    • This tool will not work without decryption keys. Do not bother installing unless you already have keys or can obtain them!

    • If you ask about keys in the issues, your message will be deleted and you will be blocked.

    • Downloading courses is against Udemy's Terms of Service, I am NOT held responsible for your account getting suspended as a result from the use of this program!

    • This program is WIP, the code is provided as-is and I am not held resposible for any legal issues resulting from the use of this program.

    Description

    Utility script to download Udemy courses, has support for DRM videos but requires the user to acquire the decryption key (for legal reasons). Windows is the primary development OS, but I've made an effort to support Linux also (Mac untested).

    [!IMPORTANT]
    This tool will not work on encrypted courses without decryption keys being provided!

    Downloading courses is against Udemy's Terms of Service, I am NOT held responsible for your account getting suspended as a result from the use of this program!

    This program is WIP, the code is provided as-is and I am not held resposible for any legal issues resulting from the use of this program.

    Requirements

    The following are a list of required third-party tools, you will need to ensure they are in your systems path and that typing their name in a terminal invokes them.

    [!NOTE]
    These are seperate requirements that are not installed with the pip command!

    You will need to download and install these manually!

    • Python 3
    • ffmpeg - This tool is also available in Linux package repositories.
      • NOTE: It is recommended to use a custom build from the yt-dlp team that contains various patches for issues when used alongside yt-dlp, however it is not required. Latest builds can be found here
    • aria2/aria2c - This tool is also available in Linux package repositories
    • yt-dlp - This tool is also available in Linux package repositories, but can also be installed using pip if desired (pip install yt-dlp)

    Usage

    You will need to get a few things before you can use this program:

    • Decryption Key ID
    • Decryption Key
    • Udemy Course URL
    • Udemy Bearer Token (aka acccess token for udemy-dl users)
    • Udemy cookies (only required for subscription plans - see Udemy Subscription Plans)

    Setting up

    • rename .env.sample to .env (only needed for Docker Compose)
    • rename keyfile.example.json to keyfile.json

    Acquire Bearer Token

    • Firefox: Udemy-DL Guide
    • Chrome: Udemy-DL Guide
    • Pass the token with -b / --bearer. It can't be combined with --browser, use one or the other.

    Key ID and Key

    [!IMPORTANT]
    For courses that are encrypted, It is up to you to acquire the decryption keys.

    Please DO NOT ask me for help acquiring these!

    • Enter the key and key id in the keyfile.json
    • keyfile example
    • example key and kid from console

    Cookies

    [!TIP] Cookies are not required for individually purchased courses.

    To download a course included in a subscription plan that you did not purchase individually, you will need to use cookies. You can also use cookies as an alternative to Bearer Tokens.

    The program can automatically extract them from your browser. You can specify what browser to extract cookies from with the --browser argument. Supported browsers are:

    • chrome
    • firefox
    • opera
    • edge
    • brave
    • chromium
    • vivaldi
    • safari

    Ready to go

    You can now run the program, see the examples below. The course will download to out_dir.

    Advanced Usage

    usage: __main__.py [-h] [-b BEARER_TOKEN] [-q QUALITY] [-l LANG] [-cd CONCURRENT_DOWNLOADS] [--skip-lectures]
                       [--download-assets] [--download-captions] [--download-quizzes] [--keep-vtt] [--skip-hls] [--info]
                       [--id-as-course-name] [-sc] [--save-to-file] [--load-from-file] [--log-level LOG_LEVEL]
                       [--browser {chrome,firefox,opera,edge,brave,chromium,vivaldi,safari,file}] [--use-h265]
                       [--h265-crf H265_CRF] [--h265-preset H265_PRESET] [--use-nvenc] [--out OUT]
                       [--continue-lecture-numbers] [--chapter CHAPTER_FILTER_RAW] [--device DEVICE]
                       course_url
    
    Udemy Downloader
    
    positional arguments:
      course_url            The URL of the course to download
    
    options:
      -h, --help            show this help message and exit
      -b, --bearer BEARER_TOKEN
                            The Bearer token to use
      -q, --quality QUALITY
                            Download specific video quality. If the requested quality isn't available, the closest quality
                            will be used. If not specified, the best quality will be downloaded for each lecture
      -l, --lang LANG       The language to download for captions, specify 'all' to download all captions (Default is
                            'en')
      -cd, --concurrent-downloads CONCURRENT_DOWNLOADS
                            The number of maximum concurrent downloads for segments (HLS and DASH, must be a number 1-30)
      --skip-lectures       If specified, lectures won't be downloaded
      --download-assets     If specified, lecture assets will be downloaded
      --download-captions   If specified, captions will be downloaded
      --download-quizzes    If specified, quizzes will be downloaded
      --keep-vtt            If specified, .vtt files won't be removed
      --skip-hls            If specified, hls streams will be skipped (faster fetching) (hls streams usually contain 1080p
                            quality for non-drm lectures)
      --info                If specified, only course information will be printed, nothing will be downloaded
      --id-as-course-name   If specified, the course id will be used in place of the course name for the output directory.
                            This is a 'hack' to reduce the path length
      -sc, --subscription-course
                            Mark the course as a subscription based course, use this if you are having problems with the
                            program auto detecting it
      --save-to-file        If specified, course content will be saved to a file that can be loaded later with --load-
                            from-file, this can reduce processing time (Note that asset links expire after a certain
                            amount of time)
      --load-from-file      If specified, course content will be loaded from a previously saved file with --save-to-file,
                            this can reduce processing time (Note that asset links expire after a certain amount of time)
      --log-level LOG_LEVEL
                            Logging level: one of DEBUG, INFO, ERROR, WARNING, CRITICAL (Default is INFO)
      --browser {chrome,firefox,opera,edge,brave,chromium,vivaldi,safari,file}
                            The browser to extract cookies from
      --use-h265            If specified, videos will be encoded with the H.265 codec
      --h265-crf H265_CRF   Set a custom CRF value for H.265 encoding. FFMPEG default is 28
      --h265-preset H265_PRESET
                            Set a custom preset value for H.265 encoding. FFMPEG default is medium
      --use-nvenc           Whether to use the NVIDIA hardware transcoding for H.265. Only works if you have a supported
                            NVIDIA GPU and ffmpeg with nvenc support
      --out, -o OUT         Set the path to the output directory
      --continue-lecture-numbers, -n
                            Use continuous lecture numbering instead of per-chapter
      --chapter CHAPTER_FILTER_RAW
                            Download specific chapters. Use comma separated values and ranges (e.g., '1,3-5,7,9-11').
      --device, -d DEVICE   Name of WVD file to use
    
    • Passing a Bearer Token and Course ID as an argument
      • python -m udemy_downloader <Course URL> -b <Bearer Token>
      • python -m udemy_downloader https://www.udemy.com/courses/myawesomecourse -b <Bearer Token>
    • Download a specific quality
      • python -m udemy_downloader <Course URL> -q 720
    • Download assets along with lectures
      • python -m udemy_downloader <Course URL> --download-assets
    • Download assets and specify a quality
      • python -m udemy_downloader <Course URL> -q 360 --download-assets
    • Download captions (Defaults to English)
      • python -m udemy_downloader <Course URL> --download-captions
    • Download captions with specific language
      • python -m udemy_downloader <Course URL> --download-captions -l en - English subtitles
      • python -m udemy_downloader <Course URL> --download-captions -l es - Spanish subtitles
      • python -m udemy_downloader <Course URL> --download-captions -l it - Italian subtitles
      • python -m udemy_downloader <Course URL> --download-captions -l pl - Polish Subtitles
      • python -m udemy_downloader <Course URL> --download-captions -l all - Downloads all subtitles
      • etc
    • Skip downloading lecture videos
      • python -m udemy_downloader <Course URL> --skip-lectures --download-captions - Downloads only captions
      • python -m udemy_downloader <Course URL> --skip-lectures --download-assets - Downloads only assets
    • Keep .VTT caption files:
      • python -m udemy_downloader <Course URL> --download-captions --keep-vtt
    • Skip parsing HLS Streams (HLS streams usually contain 1080p quality for Non-DRM lectures):
      • python -m udemy_downloader <Course URL> --skip-hls
    • Print course information only:
      • python -m udemy_downloader <Course URL> --info
    • Specify max number of concurrent downloads:
      • python -m udemy_downloader <Course URL> --concurrent-downloads 20
      • python -m udemy_downloader <Course URL> -cd 20
    • Cache course information:
      • python -m udemy_downloader <Course URL> --save-to-file
    • Load course cache:
      • python -m udemy_downloader <Course URL> --load-from-file
    • Change logging level:
      • python -m udemy_downloader <Course URL> --log-level DEBUG
      • python -m udemy_downloader <Course URL> --log-level WARNING
      • python -m udemy_downloader <Course URL> --log-level INFO
      • python -m udemy_downloader <Course URL> --log-level CRITICAL
    • Use course ID as the course name:
      • python -m udemy_downloader <Course URL> --id-as-course-name
    • Encode in H.265:
      • python -m udemy_downloader <Course URL> --use-h265
    • Encode in H.265 with custom CRF:
      • python -m udemy_downloader <Course URL> --use-h265 -h265-crf 20
    • Encode in H.265 with custom preset:
      • python -m udemy_downloader <Course URL> --use-h265 --h265-preset faster
    • Encode in H.265 using NVIDIA hardware transcoding:
      • python -m udemy_downloader <Course URL> --use-h265 --use-nvenc
    • Use continuous numbering (don't restart at 1 in every chapter):
      • python -m udemy_downloader <Course URL> --continue-lecture-numbers
      • python -m udemy_downloader <Course URL> -n
    • Download specific chapters:
      • python -m udemy_downloader <Course URL> --chapter "1,3,5" - Downloads chapters 1, 3, and 5
      • python -m udemy_downloader <Course URL> --chapter "1-5" - Downloads chapters 1 through 5
      • python -m udemy_downloader <Course URL> --chapter "1,3-5,7,9-11" - Downloads chapters 1, 3 through 5, 7, and 9 through 11
    • Download specific chapters with quality:
      • python -m udemy_downloader <Course URL> --chapter "1-3" -q 720
    • Download specific chapters with captions:
      • python -m udemy_downloader <Course URL> --chapter "1,3" --download-captions

    Support

    if you want help using the program, join my Discord server or use GitHub Issues

    Credits

    License

    All code is licensed under the MIT license

    and finally, donations!

    Woo, you made it this far!

    I spend a lot of time coding things, and almost all of them are for nothing in return. When theres a lot of use of a program I make, I try to keep it updated, fix bugs, and even implement new features! But after a while, I do run out of motivation to keep doing it. If you like my work, and can help me out even a little, it would really help me out. If you are interested, you can find all the available options here. Even if you don't, thank you anyways!