Cannot download video from udemy

See original GitHub issue

Hi there, I got 403 error when downloading course from udemy business. I used command: yt-dlp -u udemy@abc.com -p password -P '~/Downloads' -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://abc.udemy.com/course/ielts-vocab-builder-002/ I’m sure that the username/password in command is correct. Please see the log:

[debug] Command-line config: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-P', "'~/Downloads'", '-o', "'%(playlist)s/%(chapter_number)s", '-', "%(chapter)s/%(title)s.%(ext)s'", 'https://abc.udemy.com/course/ielts-vocab-builder-002/', '-v']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.09.25 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.18363-SP0
[debug] exe versions: none
[debug] Optional libraries: Crypto, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [generic] Extracting URL: -
ERROR: [generic] '-' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:-" ) to search YouTube
Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 585, in extract
  File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: '-' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:-" ) to search YouTube
Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 585, in extract
  File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: '-' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:-" ) to search YouTube

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1227, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1252, in __extract_info
  File "yt_dlp\extractor\common.py", line 601, in extract
yt_dlp.utils.ExtractorError: [generic] '-' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:-" ) to search YouTube

[debug] [generic] Extracting URL: %(chapter)s/%(title)s.%(ext)s'
ERROR: [generic] "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube
Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 585, in extract
  File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube
Traceback (most recent call last):
  File "yt_dlp\extractor\common.py", line 585, in extract
  File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1227, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1252, in __extract_info
  File "yt_dlp\extractor\common.py", line 601, in extract
yt_dlp.utils.ExtractorError: [generic] "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube

[udemy:course] Downloading login popup
ERROR: [udemy:course] course: Unable to download webpage: HTTP Error 403: Forbidden (caused by <HTTPError 403: 'Forbidden'>); please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
  File "yt_dlp\extractor\common.py", line 694, in _request_webpage
  File "yt_dlp\YoutubeDL.py", line 3256, in urlopen
  File "urllib\request.py", line 531, in open
  File "urllib\request.py", line 640, in http_response
  File "urllib\request.py", line 569, in error
  File "urllib\request.py", line 502, in _call_chain
  File "urllib\request.py", line 649, in http_error_default

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:14
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
antoine-iutcommented, Jan 23, 2022

Account shared. Answer from pukkandan: Cloudflare captcha is causing the issue. Will need to investigate further to find a solution

1reaction
hwiorncommented, Jun 30, 2022

I want to watch Udemy video on mpv for studying and note-taking. I tested 2022.06.29 and found some issues and workaround.

  1. Login check logic needs to be updated in udemy.py:L168-L171
        def is_logged(webpage):
            return any(re.search(p, webpage) for p in (
                r'href=["\'](?:https://www\.udemy\.com)?/user/logout/',
                r'>Logout<',
                r'"is_authenticated":true', # added
                fr'"email":"{username}"')) # added

Udemy login popup is updated. So it needs to be updated. But after a few successful logins, I couldn’t log in. Udemy just returnend the login popup html. I don’t know why. Maybe Udemy restriction?

  1. Captcha page of cloudflare is changed. yt-dlp needs to be updated in udemy.py:L132-L139
        if any(p in webpage for p in (
                '>Please verify you are a human',
                'Access to this page has been denied because we believe you are using automation tools to browse the website',
                '"_pxCaptcha"',
                'cf-captcha-container')): # added
            raise ExtractorError(
                'Udemy asks you to solve a CAPTCHA. Login with browser, '
                'solve CAPTCHA, then export cookies and pass cookie file to '
                'yt-dlp with --cookies.', expected=True)
  1. The course id is wrong in udemy.py:L205
    def _real_extract(self, url):
        lecture_id = self._match_id(url)

        webpage = self._download_webpage(url, lecture_id)

        course_id, _ = self._extract_course_info(webpage, lecture_id)
        #course_id = "3833504" # If I pass correct course id, it would get correct lecture info.

        try:
            lecture = self._download_lecture(course_id, lecture_id)

_real_extract passes wrong course_id to _download_lecture. It always gets 403 Forbidden. If course_id is correct, yt-dlp will download video properly. I wanted to make a PR but I couldn’t fix the 3 because I couldn’t pass playlist url which has real course_id to _real_extract.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Download Lectures to a Computer (if Enabled)
The video is taking too long to download · of the lecture so the file size for the download is smaller (see the...
Read more >
4 Ways to Download Udemy Courses on PC [All at Once]
Method 1: Download Udemy paid courses with Allavsoft. The first tool to download videos from Udemy is Allavsoft. It has a concise interface...
Read more >
Best Ways to Download Udemy Courses for Offline Viewing
If you're looking for a lightweight Udemy video downloader to download Udemy videos, you may try Video DownloadHelper. This is a popular Chrome ......
Read more >
How To Download Udemy Videos/course In 8 Secure Ways ...
Allavsoft is highly recommended to download video courses from Udemy. By default, it directly downloads Udemy videos to MP4. If you prefer to...
Read more >
How can I download Udemy course videos? - Quora
Unfortunately, Udemy doesn't allow you to download their videos due to copyright issues. However, if you save the lectures for your personal use,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found