StepicOrg / stepik-oauth2-videodownloader

Example of OAuth2 application for Stepic.org. Downloads all videofiles from a module (week) of a course.
https://stepik.org
MIT License
28 stars 13 forks source link

simplify the command line interface #5

Closed vmaks closed 8 years ago

vmaks commented 8 years ago

Hi!

I want to discuss the command line interface before implementing anything in the code.

I have used coursera-dl, edx-dl, youtube-dl apps recently.

I think we could simplify the interface for an ordinary user.

A user won't need edit any files after that. You also could put it in the pip after that.

We could delete "settings.py", "multipleDownloader.py" and rename "weekDownloader.py" to simply "downloader.py".

After that you won't be able to download multiple courses at once without external script, but ordinary user won't do it anyway, right?

By default the script will download the whole course, but you will be able to specify the week number.

I could parse input arguments with help of getopt.

An examples of usage and arguments are described below.

What do you think about that?


Example of usage

python3 downloader.py 154 --client_id="..." --client_secret="..." --week_id=1 --quality=720--output_dir=.
python3 downloader.py 154 --client_id="..." --client_secret="..." --output_dir=.
python3 downloader.py 154 --client_id="..." --client_secret="..."
python3 downloader.py 154 -c="..." -s="..."

All arguments

-h --client_id="..." --client_secret="..." --week_id=1 --quality=720 --output_dir=.

Mandatory parameters

-c, --client_id
-s, --client_secret

Optional parameters (default value in the brackets)

-w, --week_id (if not set then download the whole course)
-q, --quality (default=720)
-o, --output_dir (default=.)
-h, --help shows help
vmaks commented 8 years ago

I made a prototype.

Here the link

If you like it then I will make a pull request.

mehanig commented 8 years ago

I absolutely like it! Please make a pull request, whole idea looks great.

I barely looked into code, I think it's better to use argpase module to parse args, it also can handle --help options and other neat stuff, edx using it https://github.com/coursera-dl/edx-dl/blob/master/edx_dl/edx_dl.py#L228, and it's available for python>=3.2 and python>=2.7.

Another good option for handling command line options is Click library

It's fine to use external libraries, we already have requests, so it's up to you to choose :)

vmaks commented 8 years ago

Thank you for review! I have made a pull request. I will look at argpase module to parse args.

vmaks commented 8 years ago

I have changed getopt to argpase module to parse args.

mehanig commented 8 years ago

Looks good to me, but I didn't had a chance to test it yet. Anyway it's much readable right now with argparse and comments. I like it!

Will merge after testing. 👍

vmaks commented 8 years ago

I am glad you like it!

I think we could close the issue.

vmaks commented 8 years ago

I also thought about "don't download a video if it exists", but I don't know how to check if the video is corrupted, for example, if it contains only half of the original size, so we need to redownload it anyway.

I don't think it's critical feature, but it's simple my thoughts.