Skip to main content

Baidu Netdisk Client - A Python client for Baidu Netdisk API with CLI support

Project description

BDND - Baidu Netdisk Client

一个用于百度网盘API的Python客户端,支持通过pip安装并提供命令行工具。

GitHub License: MIT PyPI

功能特性

  • 📤 上传文件和目录到百度网盘
  • 📥 从百度网盘下载文件和目录
  • 📋 列出网盘文件
  • 📊 获取用户信息和配额信息
  • 🚀 支持断点续传
  • 📈 显示上传/下载进度条

安装

pip install bdnd

快速开始

CLI 使用

安装后,你可以直接使用 bdnd 命令:

# 上传文件到网盘
bdnd /path/to/local/file /path/on/baidu/pan

# 下载文件
bdnd /path/on/baidu/pan /path/to/local/file

# 明确指定模式
bdnd --mode upload /local/dir /remote/dir/
bdnd --mode download /remote/dir/ /local/dir/

# 指定access token
bdnd --access-token YOUR_TOKEN /local/file /remote/file

Python API 使用

from bdnd import BaiduNetdiskClient

# 创建客户端
client = BaiduNetdiskClient(access_token="YOUR_ACCESS_TOKEN")

# 上传文件
client.upload_file_auto("local_file.txt", "/remote/path/file.txt")

# 上传目录
client.upload_directory("local_dir", "/remote/dir/", recursive=True)

# 下载文件
client.download_file_by_path("/remote/path/file.txt", "local_file.txt")

# 下载目录
client.download_directory("/remote/dir/", "local_dir", recursive=True)

# 列出文件
files = client.list_files(directory="/apps/autodl")

# 获取用户信息
user_info = client.get_user_info()

# 获取配额信息
quota = client.get_quota()

配置

环境变量

你可以通过环境变量设置 access token:

export baidu_netdisk_access_token="YOUR_ACCESS_TOKEN"

CLI会自动从环境变量读取。

获取 Access Token

你需要从百度开放平台获取 access token。可以使用以下方法构建授权URL:

from bdnd import BaiduNetdiskClient

# 构建授权URL
auth_url = BaiduNetdiskClient.build_authorize_url(
    client_id="YOUR_CLIENT_ID",
    redirect_uri="oob"
)
print(auth_url)

访问该URL并授权后,可以从重定向URL中获取 access token。

依赖

  • requests
  • tqdm
  • pandas
  • urllib3
  • env-key-manager

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

项目地址: https://github.com/Rookie-Package/bdnd

更新日志

1.0.0

  • 初始版本
  • 支持文件上传/下载
  • 支持目录上传/下载
  • CLI工具支持

Project details


Download files

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

Source Distribution

bdnd-1.0.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

bdnd-1.0.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file bdnd-1.0.0.tar.gz.

File metadata

  • Download URL: bdnd-1.0.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for bdnd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 691007c2e8db1fd2f04dafe5b81f145fa12ced4ab7e4bd130377cb652c116c04
MD5 9e4548b950d00a1067446c4030cb07b9
BLAKE2b-256 7db4d095052d64aa60b9a7ebd126d818bf3d6e1cbde40a438c7af942abba7f21

See more details on using hashes here.

File details

Details for the file bdnd-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bdnd-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for bdnd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bc84a51886cd49d81b442fbbf765e3fd9e102efabe53430fff4a53c98d9d611
MD5 50dfe34628d11080a59a802de1f5e0a7
BLAKE2b-256 f3de61989f770f495eca730bb359dbea49e4020c8a568a1f6d8c7a9ed5265d3a

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