Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

nonebot-plugin-kuwo

logo

✨ 基于 NoneBot2 的酷我音乐插件 ✨

LICENSE python Adapters

uv ruff rust

基于 NoneBot2 的酷我音乐插件,面向 NapCat / OneBot V11 使用场景,提供搜索、直链、音乐卡片、语音和文件发送能力。

功能

  • kwsearch <关键词>
    • 返回搜索结果列表
    • 支持 text / image
  • kw搜索 <关键词>
    • kwsearch 中文别名
  • kw <关键词> [-q/--quality <quality>]
    • 搜索后直接取第一首歌
    • 支持 text / card / record / file
  • kwid <rid> [-q/--quality <quality>]
    • 直接通过 rid 获取歌曲
    • 支持 text / card / record / file

安装

nb-cli

nb plugin install nonebot-plugin-kuwo --upgrade

使用 PyPI 源:

nb plugin install nonebot-plugin-kuwo --upgrade -i https://pypi.org/simple
使用包管理器安装

推荐使用 uv:

uv add nonebot-plugin-kuwo

安装预发布测试版:

uv add nonebot-plugin-kuwo==0.2.7b0

安装 GitHub 仓库主分支:

uv add git+https://github.com/006lp/nonebot-plugin-kuwo@main

如果你使用其他包管理器,也可以选择:

pdm add nonebot-plugin-kuwo
poetry add nonebot-plugin-kuwo

安装后,在 NoneBot2 项目的 pyproject.toml 中加入:

plugins = ["nonebot_plugin_kuwo"]

配置

COMMAND_START=["/"]
LOG_LEVEL=INFO
RENDER_BACKEND=playwright

KUWO_SEARCH_LIMIT=5
KUWO_LIST_RENDER_MODE=text
KUWO_TRACK_RENDER_MODE=text
KUWO_DEFAULT_QUALITY=standard
# KUWO_TRACK_PROXY_URL=http://127.0.0.1:7890
KUWO_TRACK_CACHE_RETENTION_DAYS=1
KUWO_TRACK_CACHE_MAX_SIZE_MB=1024

配置项说明:

配置项 默认值 说明
KUWO_SEARCH_LIMIT 5 搜索结果条数,范围 1-10
KUWO_LIST_RENDER_MODE text 搜索列表模式,支持 text / image
KUWO_TRACK_RENDER_MODE text 单曲输出模式,支持 text / card / record / file
KUWO_DEFAULT_QUALITY standard 默认音质
KUWO_TRACK_PROXY_URL 未配置 由于版权相关问题,海外用户请求歌曲直链时需要使用境内 HTTP/HTTPS 代理,例如 http://user:pass@127.0.0.1:7890
KUWO_TRACK_CACHE_RETENTION_DAYS 1 文件缓存保留天数,0 表示关闭按天清理
KUWO_TRACK_CACHE_MAX_SIZE_MB 1024 文件缓存总大小上限,0 表示关闭按大小清理

RENDER_BACKEND 是 nonebot-plugin-htmlrender 的配置项。使用 KUWO_LIST_RENDER_MODE=image 时需要设置为 playwright;未配置时图片渲染会失败并自动回退到文本列表。当前项目已按 nonebot-plugin-htmlrender>=0.7.1 验证:默认 RENDER_STARTUP_MODE=off 时不会在 NoneBot 启动阶段预热浏览器,首次图片渲染会按需启动,详情见 nonebot-plugin-htmlrender 文档。

音质枚举:

  • standard
  • exhigh
  • lossless
  • hires
  • hifi
  • sur
  • jymaster

特殊规则:

  • KUWO_TRACK_RENDER_MODE=card 且未显式设置 KUWO_LIST_RENDER_MODE 时,搜索列表默认切到 image
  • record 模式强制回落到 standard
  • card 模式音质上限固定为 lossless
  • KUWO_TRACK_CACHE_MAX_SIZE_MB 小于 600 时仅记录警告,不阻止启动
  • KUWO_TRACK_PROXY_URL 只代理歌曲直链接口,不代理搜索、封面、详情和文件下载

使用

搜索列表

kwsearch / kw搜索 当前支持两种输出:

  • text
    • 每行格式:序号. 音乐id 歌曲名-歌手
  • image
    • 使用 nonebot-plugin-htmlrender 生成图片列表
    • 直接复用搜索接口返回的 web_albumpic_short
    • 渲染失败时自动回退到文本

单曲输出

kw / kwid 当前支持四种输出:

  • text
    • 有封面时发送 图片 + 文本
    • 文本包含:歌曲名、歌手、专辑、时长、码率、直链
    • 若接口返回 ekey,文本中会额外带上 ekey
  • card
    • 发送自定义音乐卡片
    • url 和 audio 都使用真实直链
  • record
    • 发送语音段
    • 始终使用 standard
  • file
    • 下载到本地缓存后发送文件段
    • .mflac 会先解密成可播放的 .flac
    • 上传文件名使用 [quality]歌曲名 - 歌手.扩展名,quality 为最终生效音质,例如 [lossless]Summer - rionos.flac

音质参数

kw 和 kwid 都支持:

-q
--quality

示例:

/kw Summer Pockets -q lossless
/kwid 553152678 --quality exhigh

文件缓存与 .mflac

file 模式使用 nonebot-plugin-localstore 的插件缓存目录,并在其下维护 tracks/ 子目录。

普通可直接发送的格式:

  • mp3
  • flac
  • aac
  • ogg
  • wav

缓存策略:

  • 相同 rid + bitrate 优先复用缓存
  • 缓存命中会刷新文件时间
  • 默认按 1 天和 1024MB 双重策略清理
  • 两个值都设为 0 时,不做自动清理

.mflac 流程:

  1. 下载原始 .mflac
  2. 使用 Kuwo 返回的 ekey
  3. 提取 QMC 原始密钥
  4. 推导最终 QMCv2 密钥
  5. 本地解密为 .flac
  6. 发送解密后的文件
  7. 删除中间 .mflac

反馈问题

提交 Issue 前请先搜索已有反馈,并按模板提供插件版本、NoneBot / 适配器 / 协议端版本、相关配置、触发命令和脱敏后的 DEBUG 日志。

开发

项目强制使用 uv。

uv sync
uv run maturin develop --release

常用命令:

uv run ruff check .
uv run pytest tests -q -p no:cacheprovider
cargo fmt --all

说明:

  • 发布版 wheel 会自带原生扩展 _qmc_rs
  • 源码开发或本地调试需要先执行 maturin develop

项目结构

nonebot_plugin_kuwo/
├── __init__.py
├── config.py
├── data_source.py
├── models.py
├── qmc.py
├── render.py
└── utils.py
src/
└── qmc.rs
tests/

鸣谢

许可证

本项目使用 AGPL-3.0 许可证。

Metadata

Release files for nonebot-plugin-kuwo 0.2.7b0

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

Source distribution (sdist)

Source distribution for nonebot-plugin-kuwo 0.2.7b0
File Size Uploaded
nonebot_plugin_kuwo-0.2.7b0.tar.gz 222.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for nonebot-plugin-kuwo 0.2.7b0
File
nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 1.5 MB

Release files / nonebot_plugin_kuwo-0.2.7b0.tar.gz

Download URL nonebot_plugin_kuwo-0.2.7b0.tar.gz
Size 222.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4a7ef45b4e8a29445d8e29d488d106ff6bac7a68b71a03c1a2c097dcedf59985
BLAKE2b-256 checksum
How to use checksums
115b0ea087f6d371996443fd63ef6cef42c9c8d9fdd056a15969e4eee3b291bf
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 Jun 30, 2026.

Transparency log

Release files / nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-win_arm64.whl

Download URL nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-win_arm64.whl
Size 149.6 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
e101a22cc3eb1f1355ed1e0aebde4b77c33062b9cf8ace1ddd7b1684710ebe0c
BLAKE2b-256 checksum
How to use checksums
5fe80bec52a1fea01bffc2812a6a8ea293a05a0b06dd359304aa176b6c0a5972
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 Jun 30, 2026.

Transparency log

Release files / nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-win_amd64.whl

Download URL nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-win_amd64.whl
Size 148.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d14fc7b7280b19835be256b3ac50ce67b2089ba584fc95712108317e1d09b6e7
BLAKE2b-256 checksum
How to use checksums
b5fc1e61a5066c4d19f68135725c81936f81efec8b3c53533a6ca1a27c8f7106
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 Jun 30, 2026.

Transparency log

Release files / nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 249.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9d46c7ef20f6b3476228c113a7bf42711c4ef9154c0f736d563b56f76c6aba6b
BLAKE2b-256 checksum
How to use checksums
670acbe75c23bcebc60c5ff94fcadd6978331cfd4bf43223a8c04eef7e65887b
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 Jun 30, 2026.

Transparency log

Release files / nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 240.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d636ea763b656fb9a31c2a0dd7df8f5ed75ad9e9c9a02f4b1fb54be117dcddc0
BLAKE2b-256 checksum
How to use checksums
f3ecf72358353347ec2b39c6e2cd6529e6b19c7d122cb7ad9c3803ee7791a43b
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 Jun 30, 2026.

Transparency log

Release files / nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-macosx_11_0_arm64.whl

Download URL nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-macosx_11_0_arm64.whl
Size 227.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
04d6644e0c03e31f19c8b10c1fe40f3256060aa0b7ea01cd56015874e61494ae
BLAKE2b-256 checksum
How to use checksums
91a09ad23d790c72fe29bdbc0f136b7fbdcf5606c4cf2fbe19dee0d8e20baef7
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 Jun 30, 2026.

Transparency log

Release files / nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL nonebot_plugin_kuwo-0.2.7b0-cp310-abi3-macosx_10_12_x86_64.whl
Size 226.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3f7729f35a3518439c0b773672b0e557250d00afd76d05fc6950b228924d18cc
BLAKE2b-256 checksum
How to use checksums
0c18839502a5890edd6698a2792ce29ca30ef6166641628639a9be947ca44f65
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 Jun 30, 2026.

Transparency log
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