Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s12mmm3/qcloudmusicapi
Qt C++版 网易云音乐 API
https://github.com/s12mmm3/qcloudmusicapi
api apis cloudmusic cpp neteasecloud qt qt5 qt6
Last synced: 6 days ago
JSON representation
Qt C++版 网易云音乐 API
- Host: GitHub
- URL: https://github.com/s12mmm3/qcloudmusicapi
- Owner: s12mmm3
- License: mit
- Created: 2023-09-12T04:44:34.000Z (over 1 year ago)
- Default Branch: dev
- Last Pushed: 2024-10-11T11:09:44.000Z (4 months ago)
- Last Synced: 2024-10-12T01:20:54.423Z (4 months ago)
- Topics: api, apis, cloudmusic, cpp, neteasecloud, qt, qt5, qt6
- Language: C++
- Homepage: https://s12mmm3.github.io/QCloudMusicApi/
- Size: 712 KB
- Stars: 68
- Watchers: 2
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QCloudMusicApi - Qt版 网易云音乐 API
[](https://github.com/s12mmm3/QCloudMusicApi/actions/workflows/windows.yml)
[](https://github.com/s12mmm3/QCloudMusicApi/actions/workflows/macos.yml)
[](https://github.com/s12mmm3/QCloudMusicApi/actions/workflows/ubuntu.yml)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fs12mmm3%2FQCloudMusicApi?ref=badge_shield)
[](https://www.qt.io)
[](https://www.qt.io)
## 简介
本项目翻译自Node.js项目[Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi)
更新尽量与原项目同步,实现了大部分接口;支持[跨语言调用](./doc/BINDINGS.md),支持跨平台编译,支持多种编译器编译
使用方式参考[原项目文档](https://binaryify.github.io/NeteaseCloudMusicApi),参数与返回结果与原项目完全一致;支持设置Http服务器(需要Qt6.4及以上)
### 目录
- [需求和依赖](#需求和依赖)
- [使用说明](#使用说明)
- [编译方式](#编译方式)
- [License](#License)---
## 需求和依赖
- [Qt 5.12+](https://www.qt.io/download-qt-installer)
## 使用说明
可参考文档[API 参考](./doc/API.md)
#### 使用ApiHelper类
该类实现了API的cookie管理;支持Qt反射调用
通过对应方法字符串调用
```C++
#include "apihelper.h"ApiHelper helper;
qDebug() << helper.invoke("lyric_new", { { "id", "1408586353" } });
```
传入Url调用
```C++
ApiHelper helper;
qDebug() << helper.invokeUrl("/song/url/v1?id=2058263032, 2057797340&level=exhigh");
qDebug() << helper.invokeUrl("http://localhost:3000/activate/init/profile");
```#### 使用NeteaseCloudMusicApi类
若无需保存cookie,可直接使用该类,直接调用类函数;
支持Qt反射调用,所有方法均注册至Qt元对象系统中```C++
#include "module.h"NeteaseCloudMusicApi api;
qDebug() << api.lyric_new({ { "id", "1408586353" } });
```### 跨语言调用
动态库提供C接口,开放给Python、Java和C#等支持与C语言交互的语言调用
```C++
/**
* @brief 反射调用API的成员函数。
* @param memberName 调用成员函数的名称
* @param value 参数的JSON格式字符串
* @return 调用结果的JSON格式字符串
*/
const char* invoke(char* memberName, char* value);
```调用例子参考[跨语言调用](./doc/BINDINGS.md)
### 引用动态库文件
在CMakeLists.txt文件中加上
```CMake
set(LIBRARY_DIR "${PROJECT_SOURCE_DIR}/QCloudMusicApi")
# 添加头文件路径
include_directories(${LIBRARY_DIR}/include)
# 添加库文件路径
link_directories(${LIBRARY_DIR}/bin)
```### 在项目中引用CMake项目
在CMakeLists.txt文件中加上
```CMake
add_subdirectory(QCloudMusicApi)
add_executable(${PROJECT_NAME}
./QCloudMusicApi/QCloudMusicApi/apihelper.h
main.cpp
)
target_compile_definitions(${PROJECT_NAME} PRIVATE QCLOUDMUSICAPI_LIBRARY)
target_link_libraries(${PROJECT_NAME} QCloudMusicApi)
```
引用头文件
```C++
#include "QCloudMusicApi/QCloudMusicApi/apihelper.h"
```## 编译方式
```Shell
git clone --recursive https://github.com/s12mmm3/QCloudMusicApi.git
cd QCloudMusicApi
cmake -B build
cmake --build build -j
```## License
[The MIT License (MIT)](LICENSE)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fs12mmm3%2FQCloudMusicApi?ref=badge_large)