Skip to main content

光鸭云盘 Python 客户端

PyPI version Python version License

光鸭云盘 Python 客户端库。

安装

pip install guangyaclient

快速开始

from guangyaclient import GuangyaClient

# 已有 token 直接初始化
client = GuangyaClient(access_token="your_token")

# 或使用短信登录(会自动更新 client 的 token)
client = GuangyaClient()
client.login_sms("+86 13800138000")

认证

短信登录全流程

client = GuangyaClient()

# 一键完成登录,默认通过 input() 读取验证码
client.login_sms("+86 13800138000")

# 自动化场景(传入回调)
client.login_sms(
    "+86 13800138000",
    get_code=lambda: sms_service.get_code(),
)

登录成功后 client.token、client.token_expires_at、client.refresh_token_value 自动更新。

手动刷新 Token

client.refresh_token()  # 使用已存储的 refresh_token

request() 会在 token 过期时自动刷新,也会在收到 401 时自动重试。

API 参考

用户

方法 说明
user_info() 获取当前登录用户信息

文件管理

方法 说明
fs_files(parent_id, ...) 获取文件列表
fs_image_list(parent_id, ...) 获取图片列表
fs_video_list(parent_id, ...) 获取视频列表
fs_document_list(parent_id, ...) 获取文档列表
fs_recycle_files(...) 获取回收站文件列表
fs_detail(file_id) 获取文件详情
fs_create_dir(dir_name, parent_id) 创建文件夹
fs_copy(file_ids, parent_id) 复制文件
fs_move(file_ids, parent_id) 移动文件
fs_rename(file_id, new_name) 重命名文件
fs_delete(file_ids) 删除文件(移入回收站或永久删除)
fs_recycle(file_ids) 从回收站还原文件
fs_clear_recycle_bin() 清空回收站
get_task_status(task_id) 获取任务状态

下载

方法 说明
download_url(file_id) 获取文件下载链接

上传

# 自动处理小文件直传、大文件分片上传和秒传
result = client.file_upload("/path/to/file.mp4", parent_id=123)
方法 说明
file_upload(file_path, parent_id) 上传文件(全流程)
upload_token(name, file_size, ...) 获取上传 token
check_can_flash_upload(task_id, file_path) 检查是否可秒传
cdn_upload(file_path, token_data, ...) CDN 分片上传
upload_info(task_id) 获取上传任务信息

云下载

方法 说明
cloud_task_list(page, page_size, status) 获取云下载任务列表
cloud_resolve_url(url) 解析 HTTP/磁力/ed2k 链接
cloud_resolve_torrent(torrent) 解析 BT 种子文件
cloud_create_task(url, parent_id) 创建云下载任务

分享

方法 说明
share_create(file_ids, ...) 创建分享
share_user_list(page, page_size) 获取我的分享列表
share_update(share_id, ...) 更新分享设置
share_delete(ids) 删除分享
share_restore(access_token, file_ids, parent_id) 转存分享文件
share_download_url(file_id, access_token) 获取分享文件下载链接
share_files_size(access_token, file_ids) 获取分享文件大小
share_summary(share_id) 获取分享摘要(无需登录)
share_access_token(share_id, code) 获取分享访问令牌(无需登录)
share_files_list(access_token, ...) 获取分享页文件列表(无需登录)

工具函数

from guangyaclient import calculate_gcid, generate_did, generate_traceparent, FILE_TYPE, FILE_TYPE_NAME

# 文件类型常量
FILE_TYPE["图片"]   # 1
FILE_TYPE["视频"]   # 2
FILE_TYPE_NAME[1]   # "图片"

License

MIT

Metadata

Release files for guangyaclient 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for guangyaclient 0.0.2
File Size Uploaded Provenance Actions
guangyaclient-0.0.2.tar.gz 11.1 kB With provenance Details for guangyaclient-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for guangyaclient 0.0.2
File Interpreter ABI Platform Actions
guangyaclient-0.0.2-py3-none-any.whl Python 3 none any Details for guangyaclient-0.0.2-py3-none-any.whl

Total release size: 23.7 kB

Release files / guangyaclient-0.0.2.tar.gz

Download URL guangyaclient-0.0.2.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2854eed880949dadeef24c352565db8d9623bcc4b44ff530101a7a026c7feb78
BLAKE2b-256 checksum
How to use checksums
9fa5107c111c94a89a49879cd8105a891ee410db17d4499fa1a01839a0cea0fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release files / guangyaclient-0.0.2-py3-none-any.whl

Download URL guangyaclient-0.0.2-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4aba68c96a0b5a4d6aede912a3cdf7a5bb36e9c27d1582d3e125d981e094c356
BLAKE2b-256 checksum
How to use checksums
28e0db8aeb72f9ae959c4f956f0cd9f3c5f26b438d85ea96c16e37ee8f42df62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Security for guangyaclient 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for guangyaclient-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page