光鸭云盘 Python 客户端
Project description
光鸭云盘 Python 客户端
光鸭云盘 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guangyaclient-0.0.1.tar.gz.
File metadata
- Download URL: guangyaclient-0.0.1.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc54effd19835c52182ea70e93f1dc2c5330673cb8fba59968ccbeda2cb05bd2
|
|
| MD5 |
22e3086ca59c74949992673b4c95a0c4
|
|
| BLAKE2b-256 |
7a208b677031ea0216d9c73238fc62ba299b596c32d5fcd5ae306fc7a3ad6417
|
Provenance
The following attestation bundles were made for guangyaclient-0.0.1.tar.gz:
Publisher:
publish.yml on DDSRem-Dev/guangyaclient
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
guangyaclient-0.0.1.tar.gz -
Subject digest:
bc54effd19835c52182ea70e93f1dc2c5330673cb8fba59968ccbeda2cb05bd2 - Sigstore transparency entry: 1346405028
- Sigstore integration time:
-
Permalink:
DDSRem-Dev/guangyaclient@0425bd784ee2df89ffe9c143b26ec3e157ec8245 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/DDSRem-Dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0425bd784ee2df89ffe9c143b26ec3e157ec8245 -
Trigger Event:
release
-
Statement type:
File details
Details for the file guangyaclient-0.0.1-py3-none-any.whl.
File metadata
- Download URL: guangyaclient-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a47101f0f9afa05c80aa992d2ac0ece64975e4ad0a3088ce8bb35772df950773
|
|
| MD5 |
09a9cb23d0569305db9f0ed3d33a2fb5
|
|
| BLAKE2b-256 |
309fcd867e8c76c60592bb88f59862cb24acb0bff61c3bdb3b5f6b1022965a2d
|
Provenance
The following attestation bundles were made for guangyaclient-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on DDSRem-Dev/guangyaclient
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
guangyaclient-0.0.1-py3-none-any.whl -
Subject digest:
a47101f0f9afa05c80aa992d2ac0ece64975e4ad0a3088ce8bb35772df950773 - Sigstore transparency entry: 1346405168
- Sigstore integration time:
-
Permalink:
DDSRem-Dev/guangyaclient@0425bd784ee2df89ffe9c143b26ec3e157ec8245 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/DDSRem-Dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0425bd784ee2df89ffe9c143b26ec3e157ec8245 -
Trigger Event:
release
-
Statement type: