|
5 | 5 | **网易云音乐 API Rust 原生实现** |
6 | 6 |
|
7 | 7 | [](https://www.rust-lang.org/) |
| 8 | +[](https://crates.io/crates/ncm-api-rs) |
| 9 | +[](https://github.com/imsyy/ncm-api-rs/releases) |
8 | 10 | [](LICENSE) |
9 | 11 | [](https://tokio.rs/) |
10 | 12 |
|
|
37 | 39 |
|
38 | 40 | ### 安装 |
39 | 41 |
|
40 | | -在 `Cargo.toml` 中添加依赖: |
| 42 | +#### 作为 Rust 库依赖 |
41 | 43 |
|
42 | 44 | ```toml |
43 | 45 | [dependencies] |
44 | | -ncm-api = { git = "https://github.com/imsyy/ncm-api-rs.git" } |
| 46 | +ncm-api-rs = "0.1" |
45 | 47 | tokio = { version = "1", features = ["full"] } |
46 | 48 | ``` |
47 | 49 |
|
48 | | -或使用本地路径(开发时): |
| 50 | +或从 Git 安装最新版: |
49 | 51 |
|
50 | 52 | ```toml |
51 | 53 | [dependencies] |
52 | | -ncm-api = { path = "../rust-sdk" } |
| 54 | +ncm-api-rs = { git = "https://github.com/imsyy/ncm-api-rs.git" } |
53 | 55 | tokio = { version = "1", features = ["full"] } |
54 | 56 | ``` |
55 | 57 |
|
| 58 | +#### 安装 HTTP 服务器 |
| 59 | + |
| 60 | +通过 cargo 安装: |
| 61 | + |
| 62 | +```bash |
| 63 | +cargo install ncm-api-rs --features server |
| 64 | +``` |
| 65 | + |
| 66 | +或从 [GitHub Releases](https://github.com/imsyy/ncm-api-rs/releases) 下载预编译二进制文件,支持以下平台: |
| 67 | + |
| 68 | +| 平台 | 架构 | 文件 | |
| 69 | +|------|------|------| |
| 70 | +| Linux | x64 | `ncm-server-vX.X.X-x86_64-unknown-linux-gnu.tar.gz` | |
| 71 | +| Linux | ARM64 | `ncm-server-vX.X.X-aarch64-unknown-linux-gnu.tar.gz` | |
| 72 | +| macOS | x64 | `ncm-server-vX.X.X-x86_64-apple-darwin.tar.gz` | |
| 73 | +| macOS | Apple Silicon | `ncm-server-vX.X.X-aarch64-apple-darwin.tar.gz` | |
| 74 | +| Windows | x64 | `ncm-server-vX.X.X-x86_64-pc-windows-msvc.zip` | |
| 75 | + |
| 76 | +下载后解压即可运行: |
| 77 | + |
| 78 | +```bash |
| 79 | +# Linux / macOS |
| 80 | +tar xzf ncm-server-*.tar.gz |
| 81 | +./ncm-server |
| 82 | + |
| 83 | +# Windows |
| 84 | +# 解压 zip 后双击 ncm-server.exe 或在终端运行 |
| 85 | +ncm-server.exe |
| 86 | +``` |
| 87 | + |
56 | 88 | ### 基础使用 |
57 | 89 |
|
58 | 90 | ```rust |
59 | | -use ncm_api::{create_client, Query}; |
| 91 | +use ncm_api_rs::{create_client, Query}; |
60 | 92 |
|
61 | 93 | #[tokio::main] |
62 | 94 | async fn main() { |
@@ -93,7 +125,7 @@ async fn main() { |
93 | 125 | ### 带 Cookie 使用(登录后的接口) |
94 | 126 |
|
95 | 127 | ```rust |
96 | | -use ncm_api::{create_client, Query}; |
| 128 | +use ncm_api_rs::{create_client, Query}; |
97 | 129 |
|
98 | 130 | #[tokio::main] |
99 | 131 | async fn main() { |
@@ -226,11 +258,14 @@ cargo build --release --features server --bin ncm-server |
226 | 258 | |--------|------|--------| |
227 | 259 | | `NCM_HOST` | 监听地址 | `0.0.0.0` | |
228 | 260 | | `NCM_PORT` | 监听端口 | `3000` | |
229 | | -| `CORS_ALLOW_ORIGIN` | CORS 允许的 Origin | `*`(允许所有) | |
| 261 | +| `CORS_ALLOW_ORIGIN` | CORS 允许的 Origin,支持逗号分隔多个源 | `*`(允许所有) | |
230 | 262 |
|
231 | 263 | ```bash |
232 | 264 | # 示例:自定义端口和 CORS |
233 | 265 | NCM_HOST=127.0.0.1 NCM_PORT=8080 CORS_ALLOW_ORIGIN=http://localhost:5173 cargo run --features server --bin ncm-server |
| 266 | + |
| 267 | +# 示例:允许多个源 |
| 268 | +CORS_ALLOW_ORIGIN=https://a.com,https://b.com cargo run --features server --bin ncm-server |
234 | 269 | ``` |
235 | 270 |
|
236 | 271 | ### 前端调用示例 |
@@ -275,7 +310,7 @@ const res = await axios.get('/user/playlist', { |
275 | 310 | 如果你已有 Axum 项目,可以直接集成路由: |
276 | 311 |
|
277 | 312 | ```rust |
278 | | -use ncm_api::{create_client, server::{build_app, build_app_with_config, ServerConfig}}; |
| 313 | +use ncm_api_rs::{create_client, server::{build_app, build_app_with_config, ServerConfig}}; |
279 | 314 |
|
280 | 315 | // 方式一:快速构建 |
281 | 316 | let app = build_app(create_client(None)); |
@@ -391,6 +426,7 @@ axum::serve(listener, app).await?; |
391 | 426 | | `lyric` | 歌词 | |
392 | 427 | | `lyric_new` | 逐字歌词 | |
393 | 428 | | `like` | 喜欢音乐 | |
| 429 | +| `song_like` | 喜欢歌曲(新版) | |
394 | 430 | | `likelist` | 喜欢的音乐列表 | |
395 | 431 | | `song_like_check` | 歌曲是否喜爱 | |
396 | 432 | | `scrobble` | 听歌打卡 | |
@@ -423,6 +459,7 @@ axum::serve(listener, app).await?; |
423 | 459 | | `search_hot` | 热搜列表(简略) | |
424 | 460 | | `search_hot_detail` | 热搜列表(详细) | |
425 | 461 | | `search_suggest` | 搜索建议 | |
| 462 | +| `search_suggest_pc` | 搜索建议(PC端) | |
426 | 463 | | `search_multimatch` | 搜索多重匹配 | |
427 | 464 | | `search_match` | 搜索匹配 | |
428 | 465 |
|
@@ -480,6 +517,8 @@ axum::serve(listener, app).await?; |
480 | 517 | | `comment_hot` | 热门评论 | |
481 | 518 | | `comment_like` | 点赞评论 | |
482 | 519 | | `comment_new` | 新版评论 | |
| 520 | +| `comment_reply` | 回复评论 | |
| 521 | +| `comment_delete` | 删除评论 | |
483 | 522 | | `comment_hug_list` | 抱一抱列表 | |
484 | 523 | | `comment_info_list` | 评论统计 | |
485 | 524 | | `hug_comment` | 抱一抱评论 | |
@@ -596,6 +635,11 @@ axum::serve(listener, app).await?; |
596 | 635 | | `dj_toplist_newcomer` | 电台新人榜 | |
597 | 636 | | `dj_toplist_pay` | 付费电台榜 | |
598 | 637 | | `dj_toplist_popular` | 电台热门榜 | |
| 638 | +| `dj_difm_all_style_channel` | DIFM电台 - 分类 | |
| 639 | +| `dj_difm_channel_subscribe` | DIFM电台 - 收藏频道 | |
| 640 | +| `dj_difm_channel_unsubscribe` | DIFM电台 - 取消收藏频道 | |
| 641 | +| `dj_difm_playing_tracks_list` | DIFM电台 - 播放列表 | |
| 642 | +| `dj_difm_subscribe_channels_get` | DIFM电台 - 收藏列表 | |
599 | 643 | | `dj_paygift` | 付费精品 | |
600 | 644 | | `dj_today_perfered` | 今日优选 | |
601 | 645 | | `dj_radio_top` | 电台排行 | |
@@ -788,6 +832,7 @@ axum::serve(listener, app).await?; |
788 | 832 | | `voice_lyric` | 音频歌词 | |
789 | 833 | | `voicelist_list` | 声音列表 | |
790 | 834 | | `voicelist_detail` | 声音列表详情 | |
| 835 | +| `voicelist_my_created` | 我创建的播客声音 | |
791 | 836 | | `voicelist_search` | 搜索声音列表 | |
792 | 837 | | `voicelist_list_search` | 搜索声音 | |
793 | 838 | | `voicelist_trans` | 声音转换 | |
|
0 commit comments