Commit graph

835 commits

Author SHA1 Message Date
Rogério Brito
b334efda2a Merge pull request #429 from klimenko/all-lang-subtitles
added download: all-lang-subtitles and subscripts to on-demand classes

From the pull request message:

----

> I added feature of downloading additional files for on-demand classes:
>
> * subscripts for video
> * special value "all" for download subtitles and subscripts of all available languages
> (it's changed filename, for example: file.srt->file.en.srt).

----

Thanks @klimenko for the nice contribution!
2016-01-30 05:56:10 -02:00
Rogério Brito
b52186efb7 Merge pull request #437 from balta2ar/download-supplementary-materials
Add extraction of supplementary materials in on-demand courses.

From the pull request message:
----

> Supplementary materials are usually located on the first page of a
> module. These materials include: pdf, zip, ipynb, csv and other files.
> The code uses undocumented but "reverse engineered" (in browser) method:
> https://www.coursera.org/api/onDemandSupplements.v1. The code handles
> cases when there are multiple files of different formats (extensions)
> on the same page and downloads them all. This clearly benefits to the users
> which will now automatically get all the necessary files for practical
> assignments.
>
>One remarkable downside of this change is that new lecture is now added
> to the beginning of the list of lectures. It means that lectures will
> be renumbered, which will cause downloads of old lectures (even if they
> are already downloaded). I suggest removing ongoing on-demand courses
> and downloading them again (Internet connection permitting). Alternatively,
> one can use hardlink utility to find duplicate files and turn them into
> hardlinks to save up disk space.
>
> Another minor flaw is that occasionally supplementary HTML pages are
> downloaded and saved to filenames without extensions, e.g.
>
>>  01_reading-recommending-songs-assignment_graphlab.SFrame.groupby.html#graphlab.SFrame.groupby
>
>Technically, extension here is "groupby" but that looks ugly. I consider
> this to be a very minor issue. Anyway, suggestions are welcome.

----


Thanks to @balta2ar for the outstanding work with the support for on-demand
courses!
2016-01-30 05:43:44 -02:00
Yuri Bochkarev
894d35a5bb Add tests for supplement files extraction in programming assignments 2016-01-29 22:42:10 +03:00
Yuri Bochkarev
cbe72da11a Update tests 2016-01-29 21:58:40 +03:00
Yuri Bochkarev
71b1d643c9 Extract supplementary files from [un]gradedProgramming sections
I also moved a couple of methods into a separate class CourseraOnDemand
to encapsulate all the tricks that are performed to extract links to
different types of resources.
2016-01-29 21:58:12 +03:00
Yuri Bochkarev
e7b0fec4c3 Attempt to fix Travis-CI build issues with newer version of keyring
According to this advice:
https://github.com/jaraco/keyring/issues/203#issuecomment-176296396
2016-01-28 20:46:06 +03:00
Yuri Bochkarev
1f731839e7 Add Yuri Bochkarev to AUTHORS.md 2016-01-28 04:30:18 +03:00
Yuri Bochkarev
4ea30ce8e9 Add tests and fixtures for supplementary materials extraction 2016-01-28 04:29:47 +03:00
Yuri Bochkarev
b56957266c Add extraction of supplementary materials in on-demand courses
Supplementary materials are usually located on the first page of a
module. These materials include: pdf, zip, ipynb, csv and other files.
The code uses undocumented but "reverse engineered" (in browser) method:
https://www.coursera.org/api/onDemandSupplements.v1. The code handles
cases when there are multiple files of different formats (extensions)
on the same page and downloads them all. This clearly benefits to the users
which will now automatically get all the necessary files for practical
assignments.

One remarkable downside of this change is that new lecture is now added
to the beginning of the list of lectures. It means that lectures will
be renumbered, which will cause downloads of old lectures (even if they
are already downloaded). I suggest removing ongoing on-demand courses
and downloading them again (Internet connection permitting). Alternatively,
one can use hardlink utility to find duplicate files and turn them into
hardlinks to save up disk space.

Another minor flaw is that occasionally supplementary HTML pages are
downloaded and saved to filenames without extensions, e.g.

> 01_reading-recommending-songs-assignment_graphlab.SFrame.groupby.html#graphlab.SFrame.groupby

Technically, extension here is "groupby" but that looks ugly. I consider
this to be a very minor issue. Anyway, suggestions are welcome.
2016-01-28 04:26:58 +03:00
Yuri Bochkarev
186b5b921d Fix typos 2016-01-28 04:04:44 +03:00
Dmitry Klimenko
181cae897b all is default for subtitles, new format for subtiltles files for allways 2016-01-27 18:33:50 +03:00
Dmitry Klimenko
f1b58a01d4 added download: all-lang-subtitles and subscripts to on-demand classes 2015-12-22 14:58:11 +00:00
Rogério Brito
45bdcaca4d Merge pull request #413 from balta2ar/deprecate-on-demand-option
Deprecate on demand option.

This nice pull request from @balta2ar stops the madness of having
the users know which course is of which type (which they really shouldn't
have to know, frankly).

From the original pull request message:

----

Users are very confused about `--on-demand` option. Sometimes it is required, sometimes it is not. This pull request deprecates the option. Instead, the script tries to detect course type automatically by trying all course types consecutively.

There are no tests for the feature but I think they should definitely be added. I'll do that once I figure out how to do it best. Please share your advices. For better testability, I moved consecutive course tries into a separate function.

----

This closes #387, closes #411, closes #412.
2015-09-25 15:30:36 -03:00
Yuri Bochkarev
a5f74c94c2 Cosmetic fixes after review
* Add link to coursera help page describing course types
* Print type of the course we're about to start downloading
  (for possible future debuging and troubleshooting)
2015-09-25 14:16:57 +03:00
Yuri Bochkarev
b62c2cdfb4 Better names for old-styled parsing methods of syllabus and video page
Make code more clear by adding old_style prefix to methods that
work with parsing of the old-style classes.
2015-09-24 10:21:21 +03:00
Yuri Bochkarev
f2fc5a562b Deprecate --on-demand option, try to detect class type automatically
We have received a lot of issues where people are confused about
distinction between old-style and new-style (on-demand) courses.
Sometimes --on-demand option is required, sometimes it's not.

This patch deprecates --on-demand option in favour of automatic
detection. The detection is straight forward: first, try to treat
the course as an old-style, and if the course is not found, try to
treat it as a new-style (on-demand).

Corresponding messages were adjusted (login method). Help message
for --on-demand option now advices to remove that option.
2015-09-24 10:15:24 +03:00
Rogério Brito
3a2253928c Merge pull request #405 from victorwestmann/master
Fix bug running batch file on Windows with paths with spaces.

Thanks @victorwestmann for solution and tests.
2015-09-11 16:19:55 -03:00
Victor Westmann
c360a1295e Fixed the problem of running coursera-dl.bat file using long paths with spaces in it. Now, after several tests it is working fine. 2015-09-11 13:59:12 -03:00
Victor Westmann
c9b69664bf Fixed the bug in Windows of breaking the code when running path with spaces. 2015-09-11 01:05:09 -03:00
Rogério Brito
1d9120b13a Merge pull request #404 from victorwestmann/master
Fix issue with Travis badge showing "build unknown".

Thanks @victorwestmann.
2015-09-10 23:56:47 -03:00
Victor Westmann
20d7140949 Added new Contributor: Victor Westmann. 2015-09-10 23:20:25 -03:00
Victor Westmann
8435147b86 Fixed small issue with URL. It should work in a few days now. 2015-09-10 22:39:22 -03:00
Rogério Brito
14e866ae16 Merge pull request #396 from coursera-dl/setup.py-robustness
Add more robustness to `setup.py`.

Thanks to @victorwestmann for the (private) report.
2015-09-08 00:23:52 -03:00
Rogério Brito
2e96b904a9 Merge pull request #395 from coursera-dl/selectable-resolution
Selectable resolution (fixes #389)

From my original pull request:

> This is a prototype to select the video resolution of courses.  It,
> unfortunately, only works for on-demand courses (since I don't believe
> that regular courses offer videos in resolutions other than 540p yet).
>
> The code here sucks a lot, since the program started "growing organically"
> and we have some functions with more than 10 parameters, which is a real
> madness (and we are essentially, just mimicking passing the command line
> arguments object to the functions, but in a very poor style: "unboxing"
> the parameters).
2015-09-08 00:21:55 -03:00
Rogério Brito
bedf2474d0 setup.py: Be more lenient if pandoc can't be found.
This was brought to my attention by @victorwestmann. Thanks.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-07 07:31:02 -03:00
Rogério Brito
445a8c55f5 setup.py: Cope with Python 2 vs. Python 3 difference in exceptions.
Python 2 and Python 3 disagree on the exception thrown when
`subprocess.call` can't find the program to execute.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-07 07:21:12 -03:00
Rogério Brito
43148de385 coursera/coursera_dl: Hook up the video resolution to downloads.
This is utterly disgusting and we desperately need a refactoring right now
to avoid this code duplication madness!

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-07 00:18:47 -03:00
Rogério Brito
7c42475247 coursera/coursera_dl: Add CLI option for video resolution.
This is clearly marked to be only for on-demand videos and only a few
resolutions allowed (but we actually don't filter the resolutions, since,
say, coursera may start offering 1080p videos and the user might very well
try to use that before we have an opportunity to update the program).

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-07 00:14:46 -03:00
Rogério Brito
ab504ea6c5 coursera/coursera_dl: Skeleton of video res. selection for ondemand courses.
This is still not yet hooked up with any command-line option, but that's the
easiest step.

Notice that we use '540p' as the default value for the resolution, to match
the value for regular, time-based, not on-demand courses.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-06 07:22:30 -03:00
Rogério Brito
bbaa64a674 coursera/coursera_dl: Minor rewording of user-visible message.
Is this, perhaps, more idiomatic in English?

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-06 07:13:22 -03:00
Rogério Brito
2635aa7795 coursera/coursera_dl: Add some informational messages.
We should probably substitute the video_id thing with a human-readable
string, like the name of the lecture. It is too ugly and uninformative the
way that it is at present.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-06 07:10:20 -03:00
Rogério Brito
9381b6e78b CONTRIBUTING: Add more details to help people contribute.
Due to popular demand, here are a few selected hints on how to get started
contributing with git/github in very few steps.

I may include more commands at a future date, depending on the reaction to
these notes.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>

[skip-ci]
2015-09-06 01:18:28 -03:00
Rogério Brito
dcf21422f8 CONTRIBUTING: More on the cheat sheet. 2015-09-06 00:43:01 -03:00
Rogério Brito
72923c1d39 CONTRIBUTING: Add cheatsheet of commands for contributors. 2015-09-04 20:39:53 -03:00
Rogério Brito
03b6b8f266 assets: Add logo for the project/organization.
This is a cropped version of what Victor Westmann (@victorwestmann) sent me
privately via e-mail.

About the "cropped" part above: it is a cropped version because his source
file had other proposals, but we are keeping only the one that we will use.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-09-03 19:16:10 -03:00
Rogério Brito
7ce7d56b04 setup.py: Prepare for new release.
Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-17 22:39:05 -03:00
Rogério Brito
cfa0b1b7bc setup.py: Skip creation of shipped README.rst if it exists.
This is a brown paper bag commit and fixes #354. Thanks @spl for the prompt
feedback.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-17 22:30:56 -03:00
Rogério Brito
7735306340 README: Reword to say that requirements.txt is required.
While not strictly true, it will save me a lot of headaches compared to the
situation of people using very old dependencies.  Generally, it is preferred
to have newer versions than to have older dependencies.

I don't know if `pip` supports the equivalent of Ruby's Gemfiles `~=`
operator to specify versions that don't break API compatibility with the
version specified.

I saw that mentioned in [PEP-400][pep400], but I don't know if it is
implemented already.

[pep440]: https://www.python.org/dev/peps/pep-0440/#compatible-release

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-17 04:51:27 -03:00
Rogério Brito
cc367daaab README: Be less rude with the advice.
Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-17 04:50:01 -03:00
Rogério Brito
ba018252ac README: Put more emphasis on using Python 3.
While not strictly required (I use Python 2 or Python 3 about 50% of the
time each), Python 3 has better SSL/TLS support, especially after all the
attacks on SSLv3.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-17 04:47:39 -03:00
Rogério Brito
5a060b02ad README: Promote Free Software instead of Proprietary ones. 2015-08-17 04:46:56 -03:00
Rogério Brito
b8e116e4cd CONTRIBUTING: Substitute pep8 and pyflakes by flake8. 2015-08-16 15:30:43 -03:00
Rogério Brito
d6bfc1513e fabfile: Add command to digitally sign the releases. 2015-08-16 05:09:55 -03:00
Rogério Brito
6225fa1cd2 setup.py: Prepare for another release.
With the fixed documentation.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-16 05:07:43 -03:00
Rogério Brito
a263a0ec96 setup.py: Try to fix rendering on PyPI.
PyPI doesn't seem to like pandoc's output when we use
`--from=markdown_github`.  Bummer.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-16 05:06:33 -03:00
Rogério Brito
079dabe419 setup.py: Prepare for release 0.1.0 alpha 1. 2015-08-16 04:31:48 -03:00
Rogério Brito
ef0ec5cad1 README: Make it more explicit that we support on-demand classes.
Let's hope that it bears fruits.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-16 04:15:07 -03:00
Rogério Brito
e4b17b233c coursera/cookies: Add hint to use the --on-demand option.
We have seen a significant rise in people asking if the program supports
On-Demand courses (or even claiming that it doesn't work).

See issues #386, #380, #379, #333, among many others.

This ability was contributed by @MXAmin quite some time ago and we even have
it documented in our README file, right there at the top, in the "Features"
section.

Hopefully this makes it more explicit that we *do support* such courses.

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-16 04:08:59 -03:00
Rogério Brito
1973427011 setup.py: Use some more mnemonic names for variables.
Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-16 00:03:41 -03:00
Rogério Brito
4df8c7966e setup.py: Fix #354 by generating README.rst with setup.py.
This commit makes execution of setup.py generate the README.rst file by
calling pandoc.

We only stop execution of the program if README.md can not be converted into
a README.rst file, in which case we execute the show a message to the user.

I hope that, in the future, PyPI can accept Markdown files and that we can
stop having to convert between formats (and, also, get a more faithful
reproduction of the intended markup, since some of the conversions are,
unfortunately, lossy).

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
2015-08-15 23:58:25 -03:00