Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

400 Bad Request #341

Closed
pigullino1975 opened this issue Mar 13, 2019 · 67 comments
Closed

400 Bad Request #341

pigullino1975 opened this issue Mar 13, 2019 · 67 comments
Labels
under-observation The issue will be fixed soon.

Comments

@pigullino1975
Copy link

From today, I stop downloading the courses.
I have tried many times without success ...

400

@smart-lemon
Copy link

Same here, I get this and also in the next try the error 429 (Too many requests).

@r0oth3x49 r0oth3x49 changed the title 404 Bad Request 400 Bad Request Mar 14, 2019
@r0oth3x49 r0oth3x49 added the under-observation The issue will be fixed soon. label Mar 14, 2019
@r0oth3x49
Copy link
Owner

you can use cookies based authentication until i fix the issue.

@vherasme
Copy link

vherasme commented Mar 14, 2019

you can use cookies based authentication until i fix the issue.

This works. I am downloading one of my courses. I understand they might be worried about piracy, and so they're blocking automatic downloads, but if you own a course you must have the right to download it

@kamalhm
Copy link

kamalhm commented Mar 14, 2019

how can I get my cookies?

it's actually on the readme. Sorry.

The command becomes

python udemy-dl.py [courselink] -k [yourcookiesfile.txt]

@imVinayPandya
Copy link

cookie is also not working for me

@jmishal
Copy link

jmishal commented Mar 15, 2019

Same here, even with cookie not working.

@smart-lemon
Copy link

Cookies work fine for me 🍪

@chrisjunlee
Copy link

chrisjunlee commented Mar 15, 2019

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.

So I stepped through the source code and studied the logic.

Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.

Use the cookie switch: --cookie=cookie.txt

To get the actual values, you can use a cookie chrome extension.

@jmishal
Copy link

jmishal commented Mar 15, 2019

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.

So I stepped through the source code and studied the logic.

Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.

Use the cookie switch: --cookie=cookie.txt

To get the actual values, you can use a cookie chrome extension.

yes ,, this working with me :-)
thanks

@RamAhm
Copy link

RamAhm commented Mar 16, 2019

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.

So I stepped through the source code and studied the logic.

Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.

Use the cookie switch: --cookie=cookie.txt

To get the actual values, you can use a cookie chrome extension.

Traceback (most recent call last):
File "C:\udemy-dl-master\udemy-dl.py", line 1443, in
main()
File "C:\udemy-dl-master\udemy-dl.py", line 952, in main
f_in = open(options.cookies)
FileNotFoundError: [Errno 2] No such file or directory: 'cookie.txt'

I still get this problem,
please how can I fix it
and is there any short video tutorial about cookies based authentication ?

@prateekdaniels
Copy link

prateekdaniels commented Mar 17, 2019

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.
So I stepped through the source code and studied the logic.
Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.
Use the cookie switch: --cookie=cookie.txt
To get the actual values, you can use a cookie chrome extension.

Traceback (most recent call last):
File "C:\udemy-dl-master\udemy-dl.py", line 1443, in
main()
File "C:\udemy-dl-master\udemy-dl.py", line 952, in main
f_in = open(options.cookies)
FileNotFoundError: [Errno 2] No such file or directory: 'cookie.txt'

I still get this problem,
please how can I fix it
and is there any short video tutorial about cookies based authentication ?

Same issue with me

@queeup
Copy link

queeup commented Mar 17, 2019

I think you should give exact location of cookie.txt

Example:

--cookie=/home/user/cookie.txt

@prateekdaniels
Copy link

I think you should give exact location of cookie.txt

Example:

--cookie=/home/user/cookie.txt

Have done that too, but doesnt work

@r0oth3x49
Copy link
Owner

I think you should give exact location of cookie.txt
Example:

--cookie=/home/user/cookie.txt

Have done that too, but doesnt work

i have already mention the guide to extract cookies via firefox & chrome in readme file. the error you are facing is user error and not related to the tool you can follow the guide on readme how to use the tool.

@imVinayPandya
Copy link

Hello @ALL i am firefox user and this is working for me
#303 (comment)

@jmishal
Copy link

jmishal commented Mar 19, 2019

since you used windows I guess need to used back slash for the paths instead of slash.

@anagnam
Copy link

anagnam commented Mar 20, 2019

bad request

Hello, @r0oth3x49 I hope this can be fixed soon. thanks and more power!

@varunchandak
Copy link

@anagnam This is solved by cookies. Please check the closed issues on how to do that. It's also present in the README.

@anagnam
Copy link

anagnam commented Mar 20, 2019

@varunchandak I don't think so. I've tried using cookies and it worked on the first 3 chapters. Then after that, a series of error occurs so the total 14 chapter course was not downloaded in full. only the first 3 chapters were downloaded and were not actually finished.

@jck4422
Copy link

jck4422 commented Mar 22, 2019

I had same 400 issue, then used cookies and it works! had to fix #347 before.

@Eugenio-Liso
Copy link

Worked also for me. Thanks!

@Nashaatfarrag
Copy link

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.
So I stepped through the source code and studied the logic.
Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.
Use the cookie switch: --cookie=cookie.txt
To get the actual values, you can use a cookie chrome extension.

yes ,, this working with me :-)
thanks

the file must name cookies not cookie

@prateekdaniels
Copy link

Thank @r0oth3x49! You're the champ !

@farukh2352
Copy link

Hello all.

I was able to create cookies, but latter it process failed.

[] : Trying to login using cookies ...
[+] : Logged in successfully.
[
] : Downloading course information .. -Traceback (most recent call last):
File "udemy-dl.py", line 1432, in
main()
File "udemy-dl.py", line 1091, in main
udemy.course_download(path=options.output, quality=options.quality, unsafe=options.unsafe)
File "udemy-dl.py", line 425, in course_download
course = udemy.course(url=self.url, username=self.username, password=self.password, cookies=self.cookies)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_udemy.py", line 38, in course
return Udemy(url, username, password, cookies, basic, callback)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 44, in init
super(InternUdemyCourse, self).init(*args, **kwargs)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_shared.py", line 63, in init
self._fetch_course()
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 56, in _fetch_course
self._info = self._real_extract(self._url)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 584, in _real_extract
'subtitles' : self._extract_subtitles(tracks),
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 382, in extract_subtitles
lang = track.get('language') or track.get('srclang') or track.get('label') or track['locale'].get('locale').split('
')[0]
KeyError: 'locale'

Please let me know if I am doing something wrong.

@r0oth3x49
Copy link
Owner

Hello all.

I was able to create cookies, but latter it process failed.

[] : Trying to login using cookies ... [+] : Logged in successfully. [] : Downloading course information .. -Traceback (most recent call last):
File "udemy-dl.py", line 1432, in
main()
File "udemy-dl.py", line 1091, in main
udemy.course_download(path=options.output, quality=options.quality, unsafe=options.unsafe)
File "udemy-dl.py", line 425, in course_download
course = udemy.course(url=self.url, username=self.username, password=self.password, cookies=self.cookies)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_udemy.py", line 38, in course
return Udemy(url, username, password, cookies, basic, callback)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 44, in init
super(InternUdemyCourse, self).init(*args, **kwargs)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_shared.py", line 63, in init
self._fetch_course()
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 56, in _fetch_course
self._info = self._real_extract(self._url)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 584, in _real_extract
'subtitles' : self._extract_subtitles(tracks),
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 382, in extract_subtitles lang = track.get('language') or track.get('srclang') or track.get('label') or track['locale'].get('locale').split('')[0]
KeyError: 'locale'

Please let me know if I am doing something wrong.

pull the repository. i have recently merged a patch request for this error.

@agisan
Copy link

agisan commented Mar 23, 2019

Hi! I have the same error... and I try to fix it but I don't know how to do it.
error400git Can you help me?

@farukh2352
Copy link

Hello all.

I was able to create cookies, but latter it process failed.

[] : Trying to login using cookies ... [+] : Logged in successfully. [] : Downloading course information .. -Traceback (most recent call last):
File "udemy-dl.py", line 1432, in
main()
File "udemy-dl.py", line 1091, in main
udemy.course_download(path=options.output, quality=options.quality, unsafe=options.unsafe)
File "udemy-dl.py", line 425, in course_download
course = udemy.course(url=self.url, username=self.username, password=self.password, cookies=self.cookies)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_udemy.py", line 38, in course
return Udemy(url, username, password, cookies, basic, callback)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 44, in init
super(InternUdemyCourse, self).init(*args, **kwargs)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_shared.py", line 63, in init
self._fetch_course()
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 56, in _fetch_course
self._info = self._real_extract(self._url)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 584, in _real_extract
'subtitles' : self._extract_subtitles(tracks),
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 382, in extract_subtitles lang = track.get('language') or track.get('srclang') or track.get('label') or track['locale'].get('locale').split('')[0]
KeyError: 'locale'

Please let me know if I am doing something wrong.

Hello all.
I was able to create cookies, but latter it process failed.
[] : Trying to login using cookies ... [+] : Logged in successfully. [] : Downloading course information .. -Traceback (most recent call last):
File "udemy-dl.py", line 1432, in
main()
File "udemy-dl.py", line 1091, in main
udemy.course_download(path=options.output, quality=options.quality, unsafe=options.unsafe)
File "udemy-dl.py", line 425, in course_download
course = udemy.course(url=self.url, username=self.username, password=self.password, cookies=self.cookies)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_udemy.py", line 38, in course
return Udemy(url, username, password, cookies, basic, callback)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 44, in init
super(InternUdemyCourse, self).init(*args, **kwargs)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_shared.py", line 63, in init
self._fetch_course()
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_internal.py", line 56, in _fetch_course
self._info = self._real_extract(self._url)
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 584, in _real_extract
'subtitles' : self._extract_subtitles(tracks),
File "C:\Program Files (x86)\Python37-32\udemy-dl-master\udemy_extract.py", line 382, in extract_subtitles lang = track.get('language') or track.get('srclang') or track.get('label') or track['locale'].get('locale').split('')[0]
KeyError: 'locale'
Please let me know if I am doing something wrong.

pull the repository. i have recently merged a patch request for this error.

Thank you its working now :)

@ghost
Copy link

ghost commented Apr 3, 2019

@ronkiwest your udemy-dl is old, clone again. if you login with cookie, you only need -k command and cookie.txt file

@ronkiwest
Copy link

@ronkiwest your udemy-dl is old, clone again. if you login with cookie, you only need -k command and cookie.txt file

Thanks @brundidge , updated udemy-dl , it worked.

@ipsgit2018
Copy link

how to get youraccesstokenvalue and yourclientid
for
Cookie: access_token=youraccesstokenvalue client_id=yourclientid

@ghost
Copy link

ghost commented Apr 4, 2019

@ipsgit2018 Guide Extracting Cookies in README.md works fine, you can follow that.

@chrisjunlee
Copy link

Awesome. Glad I could help. Happy learning everyone :)

@huydhoang
Copy link

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.

So I stepped through the source code and studied the logic.

Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.

Use the cookie switch: --cookie=cookie.txt

To get the actual values, you can use a cookie chrome extension.

Awesome. Glad I could help. Happy learning everyone :)

Really nice workaround. Working as of today :)

@ahmedbokhari7
Copy link

ahmedbokhari7 commented Apr 10, 2019

kindly tell me what is clientID and i have given this way in cookies.txt
Screen Shot 2019-04-10 at 11 37 49 AM

@ahmedbokhari7
Copy link

how should i execute the command with cookies
i do this
Image from iOS

@Fidozx
Copy link

Fidozx commented Apr 10, 2019

kindly tell me what is clientID
Screen Shot 2019-04-10 at 11 37 49 AM

First you need to extract the cookie and save it in a txt file. Then search client_id in this file, you will find something like client_id=joiz7896dfaioejnfoizuc8g879za8691rif9.

@ahmedbokhari7
Copy link

ahmedbokhari7 commented Apr 10, 2019

client_id
@Fidozx
how can i extract cookies ?
and what is access_token ?

@ghost
Copy link

ghost commented Apr 10, 2019

@ahmedbokhari7
Copy link

thanks :) its done

@ahmedbokhari7
Copy link

now i get this issue if i download with cookies
Screen Shot 2019-04-11 at 5 59 00 PM

@ghost
Copy link

ghost commented Apr 11, 2019

@ahmedbokhari7 Check your access_token, i think it's broken, maybe you added or deleted some characters by mistake, should be 40 chars. Make a new cookie file again is the best option.

@fdbiondi
Copy link

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.

So I stepped through the source code and studied the logic.

Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.

Use the cookie switch: --cookie=cookie.txt

To get the actual values, you can use a cookie chrome extension.

Great! this work fine
thanks!

@wldsaad
Copy link

wldsaad commented Apr 25, 2019

USING FIREFOX:

  1. open udemy and go to your courses page.
  2. right click and select "Inspect Element"
  3. choose "Network" tab
  4. right click on any get request and select "Copy > Copy as cURL"
  5. save it in a text file e.g "cookie.txt"
  6. put that text file with the main directory of "udemy-dl-master" folder
  7. open CMD and run the following command:
    python udemy-dl.py COURSE_URL -k cookie.txt
    OR
    py udemy-dl.py COURSE_URL -k cookie.txt

@shubhamjain32
Copy link

now i get this issue if i download with cookies
Screen Shot 2019-04-11 at 5 59 00 PM

Note that udemy changes access token after we select any course to view. When we login to udemy and select any course to view its videos, access token gets changed and thus becomes different from the one which is set when we have not selected any course. Thus you have to use the access token which is set after you have selected the course (same course which you have to download via command line)

@ghost
Copy link

ghost commented Apr 28, 2019

@shubhamjain-tolexo no, it doesn't change at all, stay the same because it's just a random string to identify you between requests after login. Unless you change your password or expired after 1 month or you logged out

@shubhamjain32
Copy link

@shubhamjain-tolexo no, it doesn't change at all, stay the same because it's just a random string to identify you between requests after login. Unless you change your password or expired after 1 month or you logged out

But when i logged in, i took the access token value from the browser, then used it to download the course via command line, but i got error: Udemy Says : 403 Forbidden You do not have permission to perform this action. .... But when i select the course, the access token changed and when i used this new access token to download the course via command line, it worked.

@ghost
Copy link

ghost commented Apr 28, 2019

@shubhamjain-tolexo I tried what you said but it doesn't change at all, i moved from course to course and it still the same. Maybe your cookie method has some bug in it.

@shubhamjain32
Copy link

shubhamjain32 commented Apr 28, 2019

Maybe, it has some bug. I am using chrome "edit this cookie" extension.

@ghost
Copy link

ghost commented Apr 28, 2019

@shubhamjain-tolexo Here is my method: #351 (comment)

@shubhamjain32
Copy link

Wow! what a wonderful and step-by-step guide you have made. Well i checked again, but now i am also getting the same value for the access_token. Don't know how i get different values before? Maybe i have made some mistake before. Maybe i have copied value of some other key before. Not sure.

@MRDO5
Copy link

MRDO5 commented May 11, 2020

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.

So I stepped through the source code and studied the logic.

Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.

Use the cookie switch: --cookie=cookie.txt

To get the actual values, you can use a cookie chrome extension.

THX it's help me to ))

@vnay07
Copy link

vnay07 commented May 14, 2020

Cookies Workaround

Cookies do work, but the cookie parser is very fragile with no documentation and no debug output.
So I stepped through the source code and studied the logic.
Make a text file (cookie.txt) with this exact format:

Cookie: access_token=youraccesstokenvalue client_id=yourclientid

You need the "Cookie:" tag, space separators, '=' delimiter, and absolutely no line breaks.
Use the cookie switch: --cookie=cookie.txt
To get the actual values, you can use a cookie chrome extension.

Traceback (most recent call last):
File "C:\udemy-dl-master\udemy-dl.py", line 1443, in
main()
File "C:\udemy-dl-master\udemy-dl.py", line 952, in main
f_in = open(options.cookies)
FileNotFoundError: [Errno 2] No such file or directory: 'cookie.txt'

I still get this problem,
please how can I fix it
and is there any short video tutorial about cookies based authentication ?

the problem You guys are facing is you might are saving the name wrong like cookies.txt
save the file like cookies txt is the extension don't explicitly add (.txt) in the name
I was also stuck at this problem and now its solved.

@vnay07
Copy link

vnay07 commented May 14, 2020

image

Look at this image. This is what i mean

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
under-observation The issue will be fixed soon.
Projects
None yet
Development

No branches or pull requests