coursera icon indicating copy to clipboard operation
coursera copied to clipboard

Won't authenticate.

Open henshinger opened this issue 11 years ago • 12 comments

When I try to download any file from Coursera, I get this:

Traceback (most recent call last):
  File "coursera.py", line 315, in <module>
    main()
  File "coursera.py", line 310, in main
    dl.authenticate()
  File "coursera.py", line 64, in authenticate
    self.br.form = self.br.forms().next()
StopIteration

There are people who have already solved the problem for their coursera downloaders, but this is my favorite coursera downloader.

This is what others have done to fix the problem https://gist.github.com/jetume/ac8142f104c8ae70b485 https://github.com/jplehmann/coursera/commit/6e2725edf9e5c5be88ed5a95c84f6834ada012a0

Please fix the problem. I think your coursera downloader is the best.

Thanks

henshinger avatar Mar 19 '13 04:03 henshinger

Hello, I've the same problem, and some of my courses are close to close. Thank you in advance. As @henshinger I think this is the best script to download coursera materials. Thank you again.

ghost avatar Mar 19 '13 22:03 ghost

Hello, thank you for your positive feedback. I fixed the problem. Please test the script and let me know if it still has problems.

dmotitsk avatar Mar 20 '13 02:03 dmotitsk

Thanks man. I don't know why this isn't the most popular Coursera downloader. This one's easier to use and has all the necessary features.

henshinger avatar Mar 20 '13 10:03 henshinger

@amvargash Could you show me the exact command you typed? It's working for me.

henshinger avatar Mar 20 '13 14:03 henshinger

try switching to -l info instead of -v

I think they do the same thing but I use -l info. Haven't checked the source code. but try it out.

henshinger avatar Mar 20 '13 14:03 henshinger

try adding -p 1 -t movie srt Yeah, this is pretty much hackish at this point, but I basically go with

python coursera.py strategy101-001 -e -l info -p 3 -t movie srt

and variations of it with other courses. I'm using Python 2.7. You're probably 2.7, but just to be safe, what Python version are you using?

henshinger avatar Mar 20 '13 14:03 henshinger

Sorry I couldn't help out, but this probably is a different issue since it did successfully authenticate.

henshinger avatar Mar 20 '13 14:03 henshinger

@amvargash : I noticed this issue as well. I got it work for me by using this command: ./coursera.py -l info -v calcsing-2012-001 Please tell us if this gets it working for you as well. (I'm using Python 2.7.3 as well).

@henshinger : As you can see, this command is quite non-sensical and "should not work". I spent a few minutes looking into the matter, finding out that get_parts() is being fed a logged-out page when I used either " -v " or " -l info " (and thus will return empty lists for parts and part_titles). I've got a job interview today and cannot spend any more time until after then. I hope this helps you figure it out in the mean time.

mkazin avatar Mar 20 '13 14:03 mkazin

@mkazin Thanks for the help and good luck on your job interview. I'm probably lucky today, but I could probably use your fix if I get the error.

henshinger avatar Mar 20 '13 15:03 henshinger

@amvargash: Do you use Windows? I dont' think that the command line affects this bug. It seems like that after authenticating script gets page with no downloadable materials (it can be some intermidiate login page). Can you launch script with '-l debug'? It should show you CSRF token and session ID.

dmotitsk avatar Mar 20 '13 23:03 dmotitsk

@dmotitsk: I don't, I'm working on GNU/Linux terminal behind an http-proxy (it does not block coursera) but previous version worked fine, output of the given command was:

CSRF token: fQyeTyfcZ3WBhyRNG3P4
session: None
successfully authenticated

Thank you!

ghost avatar Mar 21 '13 02:03 ghost

I was out of city for some time. Currently I'm very busy with my work, so I can't say when I fix this completely. As I see for some reason you don't get session ID in cookies. It will be very helpfull if you add instead of 73 line something like this:

page = self.br.open(self.class_login_url) print page.read()

and attach printed html code to this issue.

Thank you.

dmotitsk avatar Mar 27 '13 07:03 dmotitsk