Skip to main content

funget

Project description

Funget

一个高效的 Python 文件下载和上传工具,支持多线程下载和断点续传功能。

特性

  • 🚀 多线程下载: 支持多线程并发下载,提高下载速度
  • 📁 断点续传: 支持断点续传,避免重复下载
  • 🔧 灵活配置: 可自定义线程数、块大小等参数
  • 📤 文件上传: 支持文件上传功能
  • 🖥️ 命令行工具: 提供便捷的命令行接口
  • 📦 Python API: 提供完整的 Python API 接口

安装

pip install funget

快速开始

命令行使用

# 基本下载
funget https://example.com/file.zip

# 自定义参数
funget https://example.com/file.zip --worker 20 --block-size 200 --capacity 150

Python API

下载文件

from funget import multi_thread_download, simple_download

# 多线程下载(推荐)
multi_thread_download(
    url="https://example.com/file.zip",
    filepath="./downloads/file.zip",
    worker_num=10,
    block_size=100,
    capacity=100
)

# 简单下载
simple_download(
    url="https://example.com/file.zip",
    filepath="./downloads/file.zip"
)

上传文件

from funget import single_upload

# 上传文件
single_upload(
    file_path="./local_file.txt",
    upload_url="https://upload.example.com/api"
)

API 参考

下载函数

multi_thread_download(url, filepath=None, worker_num=10, block_size=100, capacity=100)

多线程下载文件

参数:

  • url (str): 下载链接
  • filepath (str, optional): 保存路径,默认为当前目录下的文件名
  • worker_num (int): 工作线程数,默认 10
  • block_size (int): 每个块的大小(KB),默认 100
  • capacity (int): 队列容量,默认 100

simple_download(url, filepath=None)

单线程下载文件

参数:

  • url (str): 下载链接
  • filepath (str, optional): 保存路径

download(url, filepath=None, **kwargs)

通用下载函数,自动选择最佳下载方式

上传函数

single_upload(file_path, upload_url, **kwargs)

上传单个文件

参数:

  • file_path (str): 本地文件路径
  • upload_url (str): 上传接口地址

命令行参数

funget [URL] [OPTIONS]

选项:

  • --worker INTEGER: 工作线程数(默认: 10)
  • --block-size INTEGER: 块大小,单位 KB(默认: 100)
  • --capacity INTEGER: 队列容量(默认: 100)

使用示例

下载大文件

from funget import multi_thread_download

# 下载大文件,使用 20 个线程
multi_thread_download(
    url="https://releases.ubuntu.com/20.04/ubuntu-20.04.6-desktop-amd64.iso",
    filepath="./ubuntu.iso",
    worker_num=20,
    block_size=1024  # 1MB 块大小
)

批量下载

from funget import multi_thread_download

urls = [
    "https://example.com/file1.zip",
    "https://example.com/file2.zip",
    "https://example.com/file3.zip"
]

for i, url in enumerate(urls):
    print(f"下载文件 {i+1}/{len(urls)}")
    multi_thread_download(url, filepath=f"./downloads/file_{i+1}.zip")

依赖

  • Python >= 3.7
  • funfile >= 1.0.15
  • typer-slim >= 0.15.2

许可证

本项目基于 MIT 许可证开源。

作者

贡献

欢迎提交 Issue 和 Pull Request 来改进这个项目!

更新日志

v1.0.46

  • 当前稳定版本
  • 支持多线程下载和文件上传
  • 提供命令行工具和 Python API

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

funget-1.0.47-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file funget-1.0.47-py3-none-any.whl.

File metadata

  • Download URL: funget-1.0.47-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for funget-1.0.47-py3-none-any.whl
Algorithm Hash digest
SHA256 e690c7471ddcdfe96b6024745aa02b58456100c58599f03b0f8e71318cfb2bc3
MD5 a1dca933fe03d3f72847daa892f8ec03
BLAKE2b-256 dbd6ea184547b67d02815a2056c4cf852eacf6cd27b95496db6a4da32faeb374

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page