Skip to content

Instantly share code, notes, and snippets.

Last active May 10, 2024 18:17
Show Gist options
  • Save barbietunnie/8531d9c26cd1c0668e7278c7c4ba5853 to your computer and use it in GitHub Desktop.
Save barbietunnie/8531d9c26cd1c0668e7278c7c4ba5853 to your computer and use it in GitHub Desktop.
Downloading Udemy videos with youtube-dl

How to download your Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy


  1. Get link to the course to download. e.g.
  2. Login into udemy website, save the cookie from chrome using Chrome (Cookie.txt)1 export extension. Save it to file udemy-cookies.txt
  3. Get the link of the video that you want to download. usually in format. Use the command provided below where you have to replace the {course_link} and {path_to_cookies_file} with respective paths.
$ youtube-dl {course_link} --cookies {path_to_cookies_file}
$ youtube-dl --cookies ./udemy-cookies.txt


  • If you have previously installed youtube-dl, you should update it before attempting to download your Udemy courses
    $ youtube-dl -U
  • If you want your videos to be organized by chapter and the indices included, you can specify the output flag -o
    $ youtube-dl --cookies ./udemy-cookies.txt -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s'
# List available formats
youtube-dl -u <username> -p <password> -F -o './videos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s'
# Download the specified format
youtube-dl -u <username> -p <password> -f <desired-format> -o './videos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s'
# Download specific items
youtube-dl <url> --cookies <cookies-filename> --playlist-items "<comma-separated-indices>"
# Skip specific indices
youtube-dl <url> --cookies <cookies-filename> --playlist-start START_NUMBER
Copy link

It's not working for me on Ubuntu 22.04 Output:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', 'cookies.txt', '-u', 'PRIVATE', '-p', 'PRIVATE', '-o', '%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s', '', '--verbose']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.10.6 (CPython) - Linux-5.19.0-40-generic-x86_64-with-glibc2.35
[debug] exe versions: ffmpeg 4.4.2, ffprobe 4.4.2
[debug] Proxy map: {}
[udemy:course] Downloading login popup
ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by <HTTPError 403: 'Forbidden'>); please report this issue on . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/", line 2288, in urlopen
    return, timeout=self._socket_timeout)
  File "/usr/lib/python3.10/urllib/", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

The same on macOS

Copy link

mrmattipants commented Jul 16, 2023

MrAidynShorts' comments were the most helpful. Two, in particular, were essential:

For those who are having trouble, I've _tested both the Windows & Python (2.7) versions and documented my findings, which should help.

  1. The URL Path should be formatted as follows (DO NOT Add /learn/v4/content, from the examples, to the URL Path).<course_name>/

That, alone helped get my d/l's started. The next one was a LIFE SAVER. When you have multiple courses with hundreds of chapters and lessons, restarting from the beginning is not an option.

4. If you get an Error, before you've finished Downloading the entire course, include the "**--playlist-start**" Command, to pickup where it left off.

Packt recently had a weekend of free access, and I tried to stay up all night to take advantage. I couldn't figure out how to do the playlist thing, so when a download crashed, I handled it by: a) making note of where the last course download failed, b) start the next course, and, while that was queuing and downloading, c) I would do a screen-scrape of the chapters and lessons for the course that failed the download, d) pull the scrape content into another program, extract the chapter URL listing and put it into an external file, and then e) process those as individual video downloads using the " -a file.txt" option.

Now that I've got a handle on the --playlist-start and --playlist-end, I have a lot more flexibility.

Currently, I use the --playlist-start and --playlist-end to break large multi-chapter d/l's into sections, and then run youtube-dl from more than 1 session at a time. A great time-saver.

A hint re: cookies: I tried using the "--cookies" option, but the browser add-on exported a humongous file of ALL cookies, 3200 lines, 368k. On a whim, I included both the --username / --password authentication, and the --cookies option. I created an empty "newcookies.txt" file to reference. I started a new downoad, and when it finished, youtube-dl updated the newcookies.txt with JUST THE COOKIES NECESSARY for the training website.

Thank you for the Props.
I’m glad that someone found my post to be beneficial.

~MrMattiPants (aka MrAidynShorts)

P.S. I should note that “MrAidynShorts” was actually an Account which I had created for my son. It seems that I may have, unintentionally, posted my original comment, under his profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment