June 1, 2020

After much deliberation, I was finally able to get “youtube-dl” to work with Udemy.

Udemy is basically a site where you can take online video courses.

I combined a few ideas but here’s what you have to do to download Udemy videos using ‘cookie extractor’ and ‘youtube-dl’:

  1. You have to first provide a web browser cookie that contains your previous login information.

This means that you’ll have to literally use a web browser of your choice, login to the Udemy website, and close out of the browser.

  1. You’ll then need to use a cookie extractor to finish the job.

I used this one to manually do the job: https://github.com/jdallien/cookie_extractor

There are web extensions for other browsers like Google Chrome or Mozilla Firefox as well if needed that do the same thing.

  1. Once ‘cookie extractor’ is installed successfully, you then have to point cookie extractor to the correct location.

I’ve been using ‘qutebrowser’ as my web browser, so my cookies are located in my home directory: ~/.local/share/qutebrowser/webengine/Cookies

This is the command I ran to export the ‘cookies.txt’ file successfully, and save it to the ~/Downloads directory: cookieextractor ~/.local/share/qutebrowser/webengine/Cookies > ~/Downloads/cookies.txt

  1. Then, read this ‘youtube-dl’ GitHub issue for more information as there’s a pretty good guide in the ‘Valid Cookie File’:

https://github.com/ytdl-org/youtube-dl/issues/4539

  1. Here’s an example command you need to provide to youtube-dl that

I personally used to obtain the .mp4 video of the lecture I was on, which discussed ‘Heroku’ which is basically a way to host your own apps in a cloud environment:

youtube-dl https://www.udemy.com/the-complete-web-development-bootcamp –cookies ~/Downloads/cookies.txt –playlist-items “184” -o ‘%(playlist)s/%(chapter_number)s. %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s’

And there you have it.

I can finally watch course videos on my own time without the need of streaming video players for online Udemy courses I already paid for.

Why waste the bandwidth, when you can just download it once, and never deal with buffering videos again?

‘youtube-dl’ rules, and this proves it.

Will keep learning ‘mpv’ and other related tools to make some cool scripts to share. Stay tuned.

God Bless.