python编写下载器可暂停_downloader-cli 一个用Python编写的简单下载器,带有很棒的进度条...

downloader-cli

A simple downloader written in Python with an awesome progressbar.

dw.gif

Installation

The package is available in PyPi here

Install it using

pip install downloader-cli

If you want to manuall install, clone the repo and run the following command

sudo python setup.py install

The packages available in PyPi and AUR contain the last release, if you want all the latest changes, clone the repo and install manually or wait for the next release.

Requirements

downloader-cli requires just one external module.

Usage

The script also allows some other values from the commandline.

usage: dw [-h] [-f | -c] [-e] [-q] [-v] SOURCE [TARGET]

positional arguments:

SOURCE URL of the file. Alternately a file containing URL's with

each URL in a new line can be passed.

TARGET target filepath (existing directories will be treated as

the target location)

optional arguments:

-h, --help show this help message and exit

-f, -o, --force overwrite if the file already exists

-c, --resume resume failed or cancelled download (partial sanity check)

-e, --echo print the filepath to stdout after downloading (other

output will be redirected to stderr)

-q, --quiet suppress filesize and progress info

-v, --version Show the current version

Use It

Want to use it in your project?

Import the Download class using the following.

from downloader_cli.download import Download

Download(url).download()

Above is the simplest way to use it in your app. The other arguments are optional.

Arguments

The module takes various arguments. Only one is required though.

Name

required

default

URL/file

Yes

des

No

None (Current directory is selected and the name is extracted from the URL)

overwrite

No

False

continue_download

No

False

echo

No

False

quiet

No

False

icon_done

No

icon_left

No

icon_border

No

| (If a single char is passed, it will be used for both the right and left border. If a string of 2 chars are passed, 1st char will be used as left border and the 2nd as the right border)

NOTE For details regarding the arguments, check Usage

NOTE In case the file size is not available, the bar is shown as indefinite, in which case the icon_left by default space(" ").

Other examples

In case you want to experiment with the progress bar's icons, here's some examples.

This is when I passed icon_done as # and icon_left as space.

dw_other.gif

In case a file's size is not available from the server, the progressbar is indefinite.

indefinite_bar.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值