1.0.1 • Published 1 year ago

@durka/down v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@durka/download

文件下载,主要专注视频下载

参考 aria2 项目,以及在 aria2 基础上封装的一个 electron 项目 Motrix

aria2: https://github.com/aria2/aria2 Motrix: https://github.com/agalwood/Motrix youtube-dl: https://github.com/ytdl-org/youtube-dl/ curl: https://reqbin.com/req/c-egazzayq/curl-download-file curl --limit-rate 100k -O URL

    protocol = info_dict['protocol']
    if protocol.startswith('m3u8') and info_dict.get('is_live'):
        return FFmpegFD

    if protocol == 'm3u8' and params.get('hls_prefer_native') is True:
        return HlsFD

    if protocol == 'm3u8_native' and params.get('hls_prefer_native') is False:
        return FFmpegFD

    return PROTOCOL_MAP.get(protocol, HttpFD)
    def slow_down(self, start_time, now, byte_counter):
        """Sleep if the download speed is over the rate limit."""
        rate_limit = self.params.get('ratelimit')
        if rate_limit is None or byte_counter == 0:
            return
        if now is None:
            now = time.time()
        elapsed = now - start_time
        if elapsed <= 0.0:
            return
        speed = float(byte_counter) / elapsed
        if speed > rate_limit:
            sleep_time = float(byte_counter) / rate_limit - elapsed
            if sleep_time > 0:
                time.sleep(sleep_time)

Installation

Usage

Changelog

Changelog

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

1.0.1

1 year ago

1.0.0

1 year ago