After a considerable amount of RTFM, I try to summarize here what I
discovered, namely, that the problem is actually a conjunction of many
things:
* Python 2.6 and 2.7.x (with x <= 8) don't define the constants
`ssl.PROTOCOL_TLSv1_1` and `ssl.PROTOCOL_TLSv1_2`. [They were introduced
with Python 2.7.9][0]
* Having TLS v1.1 and TLS v1.2 seem to only be available with sufficiently
new versions of OpenSSL. Again, this is reading from [the Python docs][0].
* urllib3, as a result, doesn't seem to support explicitly specifying which
which version of TLS to use, as far as I can see it (both by reading the
reading the code and by reading
https://github.com/shazow/urllib3/issues/487#issuecomment-59382798).
[0]: https://docs.python.org/2/library/ssl.html?highlight=ssl#ssl.PROTOCOL_TLSv1
Therefore, I guess that the best that we can do so far is to only request
`ssl.PROTOCOL_TLSv1` to be used. While it seems that TLS v1.0 has issues, I
hope that the packages we depend on manage to find a way to negotiate higher
versions of TLS, so that we can change that accordingly in the future.
A not so good alternative to that would be to decide dynamically (and
monkeypatch) urllib3 to see which TLS protocols we have and what we can try
to convice it to be used.
Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
Now we can download on-demand courses like 'calculus1',
'beethoven-piano-sonatas' and etc. We can download these type of courses
by providing `--on-demand` option on command line. ex:
./coursera-dl -u <email> -p <password> --on-demand calculus1
Due to the difference between this type of courses with regular courses of
Coursera, options like '--format' may not work with this feature.
Added an authentication function which implements basic
user login procedure where client clicks `Signin` button
on coursera.org website and fills his/her Email and Password
to enter. In this procedure we use API Login v3 for authentication
and there is no need of `class_name` to fetch `csrftoken`.
This can be useful for future purposes, especially for downloading
`On-Demand` courses.
Making the compatibility with Python 3.2 working when it doesn't accept the
`u` prefix for unicode strings is a pain.
I may try to fix this, but I have yet to see if it is worth it:
http://python-future.org/unicode_literals.html
Somehow the order of cookies parameters are an important fact for
coursera!, for example if there are three parameters in cookies
called: 'csrf_token', 'maestro_login_flag' and 'CAUTH' in exactly that
order, coursera doesn't accept it and redirect the request to signin
page, but if without changing parametes values and just changing their
orders: 'maestor_login_flag', 'CAUTH' and 'csrf_token', coursera accepts
it and fetches the requested page.
Updated .gitignore file to ignore virtualenv folders: 'venv2' and
'venv3'.