1

I have been recently trying to download my own Udemy courses, as I always did, with Udemy-dl software but I am having the following error:

For about a week, when I do not use token I get this:

[i] : Trying to login using session cookie
[-] : Udemy Says: 403 Forbidden session cookie seems to be expired...
[i] : Updating session cookie.. cloudscraper.exceptions.CloudflareCaptchaProvider: Cloudflare Captcha detected, unfortunately you haven't loaded an anti Captcha provider correctly via the 'captcha' parameter.

Also have these errors, but now when I use token. This is the command I used with token:

python udemy-dl.py https://www.udemy.com/course/python-course/learn/lecture/45714954?start=15#overview -k token.txt -q 1080 -o "C:\My Files"

[i] : Trying to login using session cookie
[-] : Udemy Says: 403 Forbidden session cookie seems to be expired...
[i] : Updating session cookie..
[i] : Logged in successfully.
[-] : Udemy Says: 403 Forbidden on www.udemy.com/api-2.0/users/me/subscribed-courses?fields[course]=id,url,published_title&page=1&page_size=1000&ordering=-last_accessed,-access_time&search=python-course

I have tried several times to empty cookies in by Mozilla browser, log out and in from Udemy.com and update the actual access_token at token.txt, but the error persists when I go back to python.

What should I do?

Sam Sung
  • 11
  • 1
  • 6

1 Answers1

0

I had the same problem and solved it by modifying the following file '/udemy/session.py' on line 43, change the headers parameter:

def _set_auth_headers(self, access_token="", client_id=""):
    self._headers["Authorization"] = "Bearer {}".format(access_token)
    self._headers["X-Udemy-Authorization"] = "Bearer {}".format(access_token)
    self._headers['access_token'] = access_token

def _get(self, url):
    # print(type(self._headers), '...', self._headers)
    self._headers = {
        "Cookie": "access_token=%s" % self._headers['access_token'],
    }
    session = self._session.get(url, headers=self._headers)
    ...

Unfortunately, it is only possible to download the free courses because the premium courses have DRM protection.