Skip to main content

光鸭云盘 Python 客户端

Project description

光鸭云盘 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.tokenclient.token_expires_atclient.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

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

guangyaclient-0.0.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

guangyaclient-0.0.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file guangyaclient-0.0.2.tar.gz.

File metadata

  • Download URL: guangyaclient-0.0.2.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

Hashes for guangyaclient-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2854eed880949dadeef24c352565db8d9623bcc4b44ff530101a7a026c7feb78
MD5 7cbe27bceada578951be7f8a92befccf
BLAKE2b-256 9fa5107c111c94a89a49879cd8105a891ee410db17d4499fa1a01839a0cea0fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for guangyaclient-0.0.2.tar.gz:

Publisher: publish.yml on DDSRem-Dev/guangyaclient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file guangyaclient-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: guangyaclient-0.0.2-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

Hashes for guangyaclient-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4aba68c96a0b5a4d6aede912a3cdf7a5bb36e9c27d1582d3e125d981e094c356
MD5 b74ecd99511bfd9522e8aadd36dcbdd1
BLAKE2b-256 28e0db8aeb72f9ae959c4f956f0cd9f3c5f26b438d85ea96c16e37ee8f42df62

See more details on using hashes here.

Provenance

The following attestation bundles were made for guangyaclient-0.0.2-py3-none-any.whl:

Publisher: publish.yml on DDSRem-Dev/guangyaclient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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