coursera-dl / edx-dl

A simple tool to download video lectures from edx.org (and other openedx sites)
GNU Lesser General Public License v3.0
1.92k stars 638 forks source link

Error 403: Forbidden (Every single time.) #628

Open ulissesBR opened 3 years ago

ulissesBR commented 3 years ago

Subject of the issue

Every single time I try to access edx using any edx-dl command I get error 403 - forbidden - as a return.

Your environment

Steps to reproduce

1) Open a Powershell window in Edx-dl folder. 2) Type "edx-dl -u [username] --list-courses", for example. 3) Pray.

Expected behaviour

List my courses. Or, in the case I use a download command, download an specific course.

Actual behaviour

edx-dl -u [my_email]@gmail.com --list-courses --debug root[main] edx_dl version 0.1.13 root[parse_file_formats] file_formats: ['e?ps', 'pdf', 'txt', 'doc', 'xls', 'ppt', 'docx', 'xlsx', 'pptx', 'odt', 'ods', 'odp', 'odg', 'zip', 'rar', 'gz', 'mp3', 'R', 'Rmd', 'ipynb', 'py'] Password: root[edx_get_headers] Building initial headers for future requests. root[_get_initial_token] Getting initial CSRF token. Traceback (most recent call last): File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\Ulisses\AppData\Local\Programs\Python\Python38-32\Scripts\edx-dl.exe__main__.py", line 7, in File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\site-packages\edx_dl\edx_dl.py", line 1005, in main headers = edx_get_headers() File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\site-packages\edx_dl\edx_dl.py", line 430, in edx_get_headers 'X-CSRFToken': _get_initial_token(EDX_HOMEPAGE), File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\site-packages\edx_dl\edx_dl.py", line 167, in _get_initial_token opener.open(url) File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\urllib\request.py", line 531, in open response = meth(req, response) File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\urllib\request.py", line 640, in http_response response = self.parent.error( File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\urllib\request.py", line 569, in error return self._call_chain(args) File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\urllib\request.py", line 502, in _call_chain result = func(args) File "c:\users\ulisses\appdata\local\programs\python\python38-32\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden

jrubin01 commented 3 years ago

+1

THolding commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

ulissesBR commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

I had just tried it... But it still does not work... The problem persists. =/

Did it worked for you?

Thanks

THolding commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

I had just tried it... But it still does not work... The problem persists. =/

Did it worked for you?

Thanks

Sorry that it didn't work for you. This is just how I fixed my own copy. Do you get the same error/s? If so make sure you're changing the edx_dl.py file in the installed version you run. Or you could try making a new Python environment, installing it fresh and then changing the file in this environment. Other than that I'm unlikely to be able to help much.

mor3dr3ad commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

Worked for me +1

ulissesBR commented 3 years ago

It worked for me

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

I had just tried it... But it still does not work... The problem persists. =/ Did it worked for you? Thanks

Sorry that it didn't work for you. This is just how I fixed my own copy. Do you get the same error/s? If so make sure you're changing the edx_dl.py file in the installed version you run. Or you could try making a new Python environment, installing it fresh and then changing the file in this environment. Other than that I'm unlikely to be able to help much.

It worked for me yesterday! That was just what you said: I was using Python version 2.7. When I used py -m to run the script with Python version 3.8 (and the User-Agent change) it worked like a charm! Thank you!

MLXVI commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

Worked for me. Thanks.

mmuqiitf commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

It works! Thank you!

riverain commented 3 years ago

It worked for me, thanks!

prayasbat commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

I had just tried it... But it still does not work... The problem persists. =/ Did it worked for you? Thanks

Sorry that it didn't work for you. This is just how I fixed my own copy. Do you get the same error/s? If so make sure you're changing the edx_dl.py file in the installed version you run. Or you could try making a new Python environment, installing it fresh and then changing the file in this environment. Other than that I'm unlikely to be able to help much.

iam still facing the problem. can you help, please?

MuradShafiyev commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

I had just tried it... But it still does not work... The problem persists. =/ Did it worked for you? Thanks

Sorry that it didn't work for you. This is just how I fixed my own copy. Do you get the same error/s? If so make sure you're changing the edx_dl.py file in the installed version you run. Or you could try making a new Python environment, installing it fresh and then changing the file in this environment. Other than that I'm unlikely to be able to help much.

iam still facing the problem. can you help, please?

+1

phaneshavr commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

Did not work for me. Still getting the same error.

manzuni commented 3 years ago

I'm not an author of the tool, but you can fix it by changing line 425 of edx_dl.py which specifies the User-Agent attribute of the http request header. Change 'User-Agent': 'edX-downloader/0.01', to 'User-Agent': 'Mozilla/5.0', and it will work.

It worked for me, however now i get empty folders, nothing downloads