NoneBot2 plugin for Kuwo music search and track delivery.
Project description
nonebot-plugin-kuwo
基于 NoneBot2 的酷我音乐插件,面向 NapCat / OneBot V11 使用场景,提供搜索、直链、音乐卡片、语音和文件发送能力。
当前实现重点:
- 命令解析使用
nonebot-plugin-alconna - 消息输出统一使用
uniseg - 配置统一使用
get_plugin_config(Config) - 文件缓存统一使用
nonebot-plugin-localstore .mflac解密核心使用Rust + PyO3 + maturin
功能
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
安装后在 NoneBot 项目中启用插件:
[tool.nonebot]
plugins = ["nonebot_plugin_kuwo"]
配置
COMMAND_START=["/"]
LOG_LEVEL=INFO
KUWO_SEARCH_LIMIT=5
KUWO_LIST_RENDER_MODE=text
KUWO_TRACK_RENDER_MODE=text
KUWO_DEFAULT_QUALITY=standard
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_CACHE_RETENTION_DAYS |
1 |
文件缓存保留天数,0 表示关闭按天清理 |
KUWO_TRACK_CACHE_MAX_SIZE_MB |
1024 |
文件缓存总大小上限,0 表示关闭按大小清理 |
音质枚举:
standardexhighlosslesshireshifisurjymaster
特殊规则:
KUWO_TRACK_RENDER_MODE=card且未显式设置KUWO_LIST_RENDER_MODE时,搜索列表默认切到imagerecord模式强制回落到standardcard模式音质上限固定为losslessKUWO_TRACK_CACHE_MAX_SIZE_MB小于600时仅记录警告,不阻止启动
使用
搜索列表
kwsearch / kw搜索 当前支持两种输出:
text- 每行格式:
序号. 音乐id 歌曲名-歌手
- 每行格式:
image- 使用
nonebot-plugin-htmlrender生成图片列表 - 直接复用搜索接口返回的
web_albumpic_short - 渲染失败时自动回退到文本
- 使用
单曲输出
kw / kwid 当前支持四种输出:
text- 有封面时发送
图片 + 文本 - 文本包含:歌曲名、歌手、专辑、时长、码率、直链
- 若接口返回
ekey,文本中会额外带上ekey
- 有封面时发送
card- 发送自定义音乐卡片
url和audio都使用真实直链
record- 发送语音段
- 始终使用
standard
file- 下载到本地缓存后发送文件段
.mflac会先解密成可播放的.flac
音质参数
kw 和 kwid 都支持:
-q
--quality
示例:
/kw Summer Pockets -q lossless
/kwid 553152678 --quality exhigh
文件缓存与 .mflac
file 模式使用 nonebot-plugin-localstore 的插件缓存目录,并在其下维护 tracks/ 子目录。
普通可直接发送的格式:
mp3flacaacoggwav
缓存策略:
- 相同
rid + bitrate优先复用缓存 - 缓存命中会刷新文件时间
- 默认按
1天和1024MB双重策略清理 - 两个值都设为
0时,不做自动清理
.mflac 流程:
- 下载原始
.mflac - 使用 Kuwo 返回的
ekey - 提取 QMC 原始密钥
- 推导最终 QMCv2 密钥
- 本地解密为
.flac - 发送解密后的文件
- 删除中间
.mflac
开发
项目强制使用 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-adapter-onebot
项目结构
nonebot_plugin_kuwo/
├── __init__.py
├── config.py
├── data_source.py
├── models.py
├── qmc.py
├── render.py
└── utils.py
src/
└── qmc.rs
tests/
鸣谢
- LiuLang 提供 DES 解密算法思路
- UnblockNeteaseMusic/server 提供音乐直链接口
许可证
本项目使用 AGPL-3.0 许可证。
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 Distributions
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 nonebot_plugin_kuwo-0.2.2.tar.gz.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2.tar.gz
- Upload date:
- Size: 211.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c3872a7508c0bc2511a9d43e9e6cf1b98f81919670c9e7bb6c265f8afa53eeb
|
|
| MD5 |
ee55d632b29844478c64c9e65b1bf89e
|
|
| BLAKE2b-256 |
2818ba05770bb42bc8a72401ebed3e12c06cb66f87bd023f8230be80468b06e6
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2.tar.gz:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2.tar.gz -
Subject digest:
3c3872a7508c0bc2511a9d43e9e6cf1b98f81919670c9e7bb6c265f8afa53eeb - Sigstore transparency entry: 1394054157
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 148.1 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02ca59f0ce839330e02728f18d38811e04d16eb8593b02988af7d461874e4a87
|
|
| MD5 |
1d11224e76a0a92dfe5dce9bf9b4fcad
|
|
| BLAKE2b-256 |
f9c057239e7ca122ac07e50d072eb233bda8b44781ee87d07b3f9912b9df018f
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_arm64.whl:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_arm64.whl -
Subject digest:
02ca59f0ce839330e02728f18d38811e04d16eb8593b02988af7d461874e4a87 - Sigstore transparency entry: 1394054369
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 148.8 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5ffd1c8099550379d1ca7e26c31a1c825122c574a47e9b90e4fb6d62932f2ff
|
|
| MD5 |
f63758ef19e6bd5b0d831ee2c6ff82ce
|
|
| BLAKE2b-256 |
ed3883d1d8e645a5e48f748c0067035548c835b90905d69851e2479632d36642
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2-cp310-abi3-win_amd64.whl -
Subject digest:
c5ffd1c8099550379d1ca7e26c31a1c825122c574a47e9b90e4fb6d62932f2ff - Sigstore transparency entry: 1394054329
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 247.7 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11f327d1426f185621c0c6820ffed2995b0b4fb8e3d2b3d17e9cd9688cedfb37
|
|
| MD5 |
4eab5ca1cddd38c30ed3f816a9ad9766
|
|
| BLAKE2b-256 |
a6f237a1c1114c1ffaad3c785d68cba39e88c006a25d99c211e0162cb1ce91b9
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
11f327d1426f185621c0c6820ffed2995b0b4fb8e3d2b3d17e9cd9688cedfb37 - Sigstore transparency entry: 1394054415
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 239.6 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
207ea47a5a3cb99b6639de6f23eb54033d411274a5d063ccaaf8d237402f8dee
|
|
| MD5 |
d38fde7a720999d4dcb09c5f8265fa08
|
|
| BLAKE2b-256 |
88d451c9e672d3de6bb1bd2b7a159244b45e4fbeb6ae6bcc226f8c929d5765ab
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
207ea47a5a3cb99b6639de6f23eb54033d411274a5d063ccaaf8d237402f8dee - Sigstore transparency entry: 1394054206
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 224.6 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c01ca7f8b4aca05418b019532aa6c525225d79d55ef01b13d9d3472429e839
|
|
| MD5 |
46e72074762fc7d068f6829faba53630
|
|
| BLAKE2b-256 |
0d75a14222cddccbc4d9dfc562b6891e003678cb777c406686e282fdd4700edb
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
39c01ca7f8b4aca05418b019532aa6c525225d79d55ef01b13d9d3472429e839 - Sigstore transparency entry: 1394054251
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 225.3 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c836125073aa9ae724c72adc87dcf6c398ec917f11c89a9910b49dba48545d94
|
|
| MD5 |
7deeeb34577c402b6997de48ffd9ca24
|
|
| BLAKE2b-256 |
b92d17f1c08565165e44d6eaa91b9e88ddefe660bce669007e54cc114613db95
|
Provenance
The following attestation bundles were made for nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on 006lp/nonebot-plugin-kuwo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_kuwo-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
c836125073aa9ae724c72adc87dcf6c398ec917f11c89a9910b49dba48545d94 - Sigstore transparency entry: 1394054288
- Sigstore integration time:
-
Permalink:
006lp/nonebot-plugin-kuwo@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/006lp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@94a97a47e5b37cb771f6f059c4f24e0f57e0171b -
Trigger Event:
push
-
Statement type: