Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
Last active November 22, 2024 21:03
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

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  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 https://www.udemy.com/course-name/

Notes

  • 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' https://www.udemy.com/course-name/
    
# List available formats
youtube-dl -u <username> -p <password> -F -o './videos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/course-name/
# 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' https://www.udemy.com/course-name/
# 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
@thefsboking
Copy link

I keep getting this error. I can only download the first video in the course.
I've tried using --playlist-start 2 but still get same error.
Any suggestions?

[download] 100% of 294.16MiB
[download] Downloading video 2 of 51
[udemy] 3687216: Downloading webpage
[udemy] 3687216: Downloading lecture JSON
ERROR: unable to download video data: HTTP Error 403: Forbidden

@Xonshiz
Copy link

Xonshiz commented May 21, 2021

I've got a non-biz account and I've been trying to download, but, all I am getting is a 403. I've tried with cookie and login details, both and nothing worked. Removed that /courses/ from the URL as well, still no luck.
For me, yt-dl isn't able to even get the metadata JSON... :/

@ScrubDonkey
Copy link

The show's over guys...DRM has killed it. They should just offer a damn offline viewer already that's not Android.IOS based already. We wouldn't need to go through these hoops and hurdles.

@arulrajnet
Copy link

The chrome plugin for download cookies is no longer available. Use the following Chrome extension to download cookies

https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid/

@ZeinabBahaa
Copy link

youtube-dl --cookies cookies.txt https://www.udemy.com/course/learn-sql-basics-for-beginners-in-arabic-2021/

youtube-dl --cookies cookies.txt https://www.
udemy.com/course/learn-sql-basics-for-beginners-in-arabic-2021/
[udemy:course] course: Downloading webpage
ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by <HTTPErr
or 403: 'Forbidden'>); please report this issue on https://yt-dl.org/bug . Make
sure you are using the latest version; see https://yt-dl.org/update on how to
update. Be sure to call youtube-dl with the --verbose flag and include its compl
ete output.

@fhcaglayan
Copy link

I get an error when trying to download from udemy:

C:>youtube-dl.exe -u **** -p **** https://www.udemy.com/course/learn-advanced-java/ --verbose
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', 'https://www.udemy.com/course/learn-advanced-java/', '--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: none
[debug] Proxy map: {}
[udemy:course] Downloading login popup
ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . 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 "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\common.py", line 634, in _request_webpage
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 2288, in urlopen
File "C:\Python\Python34\lib\urllib\request.py", line 470, in open
File "C:\Python\Python34\lib\urllib\request.py", line 580, in http_response
File "C:\Python\Python34\lib\urllib\request.py", line 508, in error
File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
File "C:\Python\Python34\lib\urllib\request.py", line 588, in http_error_default

@darkjedeye
Copy link

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).
    https://www.udemy.com/<course_name>/
  2. To Download the Course Videos, as is (Lacking File Name and/or Directory Organization) use the following Command:
    youtube-dl -u user@domain.com -p P@ssw0rd https://www.udemy.com/mta-windows-server-administration-fundamentals/
  3. To Download the Course Videos, w/ Folder & File Organization, use the following.
    youtube-dl -u user@domain.com -p P@ssw0rd -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' https://www.udemy.com/mta-windows-server-administration-fundamentals/
  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.
    NOTE: From experience, most Errors tend to be thrown during the "Downloading Webpage" or "Downloading JSON" Stages, just before Downloading the Video File, itself. Therefore, if an Error was thrown just after Video #20 has Finished Downloading and Video #21 is Starting Up, simply insert --playlist-start 21 at the end of the previous command, above (as seen in the example, below).
    youtube-dl -u user@domain.com -p P@ssw0rd -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' https://www.udemy.com/mta-windows-server-administration-fundamentals/ --playlist-start 21

I hope this helps those who may be struggling to Download your Udemy Courses, etc.

I tried all the method listed here, and what helped me is using username & password, removing /course out of the url, changing https:// to http:// and --cookies ./cookiefile.txt

@darkjedeye
Copy link

youtube-dl.exe -u **** -p **** https://www.udemy.com/course/learn-advanced-java/ --verbose

try youtube-dl.exe -u **** -p **** -f 'best' http://www.udemy.com/learn-advanced-java/ --verbose

@MesterPerfect
Copy link

youtube-dl.exe -u **** -p **** https://www.udemy.com/course/learn-advanced-java/ --verbose

try youtube-dl.exe -u **** -p **** -f 'best' http://www.udemy.com/learn-advanced-java/ --verbose

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-f', "'best'", 'h
ttps://www.udemy.com/course/output_python/', '--verbose']
[debug] Encodings: locale cp1256, fs utf-8, out utf-8, pref cp1256
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.9.7 (CPython) - Windows-8.1-6.3.9600-SP0
[debug] exe versions: none
[debug] Proxy map: {}
[udemy:course] Downloading login popup
ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by <HTTPErr
or 403: 'Forbidden'>); please report this issue on https://yt-dl.org/bug . Make
sure you are using the latest version; see  https://yt-dl.org/update  on how to
update. Be sure to call youtube-dl with the --verbose flag and include its compl
ete output.
  File "c:\program files\python39\lib\site-packages\youtube_dl\extractor\common.
py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "c:\program files\python39\lib\site-packages\youtube_dl\YoutubeDL.py", li
ne 2288, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "c:\program files\python39\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "c:\program files\python39\lib\urllib\request.py", line 632, in http_resp
onse
    response = self.parent.error(
  File "c:\program files\python39\lib\urllib\request.py", line 561, in error
    return self._call_chain(*args)
  File "c:\program files\python39\lib\urllib\request.py", line 494, in _call_cha
in
    result = func(*args)
  File "c:\program files\python39\lib\urllib\request.py", line 641, in http_erro
r_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

@jetonr
Copy link

jetonr commented Nov 1, 2021

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-f', "'best'", 'https://www.udemy.com/wordpress-for-beginners-course/', '--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.19041
[debug] exe versions: none
[debug] Proxy map: {}
[udemy:course] Downloading login popup
ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . 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 "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\common.py", line 634, in _request_webpage
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 2288, in urlopen
File "C:\Python\Python34\lib\urllib\request.py", line 470, in open
File "C:\Python\Python34\lib\urllib\request.py", line 580, in http_response
File "C:\Python\Python34\lib\urllib\request.py", line 508, in error
File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
File "C:\Python\Python34\lib\urllib\request.py", line 588, in http_error_default

@yaakov1111
Copy link

is there any way our days to download a paid course from UDEMY ?

@Alex2357
Copy link

Did a number of attempts today nothing worked. Anyone knows solution?

2 Udemy what the hell you're doing? I have purchased a course and I can't watch it offline on my desktop. Why is that? Do not suggest me mobile device just because screen is small and I'd like to make notes for myself with some important keys from video. It is not a movie to watch on mobile. It needs to be watched on desktop to see letters and be able to make notes for myself whcih I can review few times before doing certification.
Seriously I wanted to purchase few more courses but hell no. It was enough I'm not gonna buy anymore until I have the option to watch them offline on my laptop.

@MesterPerfect
Copy link

youtube dl will not solve the problem
There are two solutions
first: watch udemy courses via browser and download videos using download manager
or
Use this program
https://github.com/FaisalUmair/udemy-downloader-gui
or
https://github.com/r0oth3x49/udemy-dl

@rajhlinux
Copy link

rajhlinux commented Mar 20, 2022

not working for me:

this is what I type:

C:\Users\Admin\Downloads\Programs>C:\Users\Admin\Downloads\Programs\youtube-dl.exe --cookies C:\Users\Admin\Downloads\udemy.com_cookies.txt -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' https://www.udemy.com/course/day-trading-strategies-day-trading-with-technical-analysis/

and this is what i get as output:

ERROR: '-' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:-" ) to search YouTube

Whats wrong?

Thanks

EDIT:

Good luck downloading videos from udemy.com
Long story short, you simply can not do it. I tried all the "easy" methods...
Udemy started using Google's Widevine DRM protocols to encrypt their popular contents.
Previous "hacks" for widevine does not work, because google and udemy have updated/patched those hacks.

It can be done, but you'll need to do your "homework"... no one wants freeloaders to be flooded all over on udemy just so udemy and google can "update" the current method of downloading DRM content which is already ridiculously difficult alone for bypassing.

And lastly, for those who do not pay for content are seriously harming Udemy's content creators.

@dirkf
Copy link

dirkf commented Apr 27, 2022

Whats wrong?

Use "double-quotes" in Windows cmd.

@PartTimeJS
Copy link

Seeing this:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', 'D:\\Downloads\\udemy.com_cookies.txt', '-o', '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s', 'https://www.udemy.com/course/cissp-domain-1-2', '--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.22593
[debug] exe versions: none
[debug] Proxy map: {}
[udemy:course] course: Downloading webpage
[udemy:course] 1348924: Downloading course curriculum
[download] Downloading playlist: 1348924
[udemy:course] playlist 1348924: Collected 46 video ids (downloading 46 of them)
[download] Downloading video 1 of 46
[udemy] 8499446: Downloading webpage
[udemy] 8499446: Downloading lecture JSON
[udemy] 8499446: Downloading lecture JSON
ERROR: Unable to download JSON metadata: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . 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 "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\extractor\common.py", line 634, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\YoutubeDL.py", line 2288, in urlopen
  File "C:\Python\Python34\lib\urllib\request.py", line 470, in open
  File "C:\Python\Python34\lib\urllib\request.py", line 580, in http_response
  File "C:\Python\Python34\lib\urllib\request.py", line 508, in error
  File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
  File "C:\Python\Python34\lib\urllib\request.py", line 588, in http_error_default```

@dirkf
Copy link

dirkf commented Apr 27, 2022

See ytdl-org/youtube-dl#30901 and the linked issues.

@CoderHarshvirSingh
Copy link

Hi @guys, today I've just tried to download course from Udemy using cookies.txt approach and see it's still working fine. Followings are the steps I use to download Udemy course:
Open Chrome and add extension cookies.txt from Genuinous.
Login to Udemy website and click that extension to download cookie file named cookies.txt.
Put this cookie file inside the folder you want to download.
Followings are some examples of cmd to download the course:

# Download with human-generated subtitle.
youtube-dl --write-sub --sub-lang en --cookies cookies.txt -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' https://www.udemy.com/aws-certified-solutions-architect-associate-saa-c02/

# Download with auto-generated subtitle.
youtube-dl --write-auto-sub --sub-lang en --cookies cookies.txt -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' https://www.udemy.com/aws-certified-solutions-architect-associate-saa-c02/

NOTE: Make sure there's no /course/ in the url.

Hope it helps. Cheers.

tested with personal account and working fine

its working fine

@PrajyotGajane
Copy link

@CoderHarshvirSingh how were you able to ?
I ran the same command with another course it, downloaded 2 videos and then it failed, everytime.

@arcanjoebc1971
Copy link

I don't speak English, but I speak Portuguese from Brazil, ok! However, I know some vocabulary in English and I get create simple sentences ... I followed the pass by pass, but it appear an error. Someone can help me?

`[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', './udemy-cookies.txt', '-u', 'PRIVATE', '-p', 'PRIVATE', '-o', '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s', 'https://www.udemy.com/course/aprendacobol/learn/lecture/26407936?start=465#content', '--verbose']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.9.2 (CPython) - Linux-5.10.0-19-amd64-x86_64-with-glibc2.31
[debug] exe versions: ffmpeg 4.3.4-0, ffprobe 4.3.4-0, rtmpdump 2.4
[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 https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
File "/usr/lib/python3/dist-packages/youtube_dl/extractor/common.py", line 634, in _request_webpage
return self._downloader.urlopen(url_or_request)
File "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 2288, in urlopen
return self._opener.open(req, timeout=self._socket_timeout)
File "/usr/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/usr/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)

`

@dayarbro1
Copy link

dayarbro1 commented Oct 26, 2022 via email

@ronaldchaula
Copy link

@CoderHarshvirSingh how were you able to ?
I ran the same command with another course it, downloaded 2 videos and then it failed, everytime.

I also face the same problem it actually downloaded a single video and some sub title

@JamesDAdams
Copy link

JamesDAdams commented Feb 22, 2023

Not work for my 403 error :

[udemy:course] course: Downloading webpage
[udemy:course] 4283448: Downloading course curriculum
ERROR: Unable to download JSON metadata: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . 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.```

@MesterPerfect
Copy link

Not work for my 403 error :

[udemy:course] course: Downloading webpage
[udemy:course] 4283448: Downloading course curriculum
ERROR: Unable to download JSON metadata: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . 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.```

Are you using Linux or Windows?

@ssukhawani
Copy link

this extension cookies.txt from Genuinous. is not available on chrome

@cloudmusic9
Copy link

cloudmusic9 commented Mar 31, 2023

@CoderHarshvirSingh The (playlist) was empty, the (chapter_number), (playlist_index) & (ext) etc inside output name pattern were not replaced, how should this be fixed?

(i am using windows)

@aldinokemal
Copy link

aldinokemal commented Apr 1, 2023

has not worked anymore

@Seb90258
Copy link

Seb90258 commented May 8, 2023

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', 'https://www.udemy.com/course/python-the-complete-python-developer-course/', '--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 https://yt-dl.org/bug . 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/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2288, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

@andreypudov
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', 'https://www.udemy.com/course/python-the-complete-python-developer-course/', '--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 https://yt-dl.org/bug . 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/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2288, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

The same on macOS

@mrmattipants
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).
    https://www.udemy.com/<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