Giter Site home page Giter Site logo

qcloudmusicapi's Introduction

QCloudMusicApi

Qt版 网易云音乐 API

简介

本项目翻译自Node.js项目Binaryify/NeteaseCloudMusicApi

更新尽量与原项目同步,实现了部分接口

使用方式请参考原项目文档,参数与返回结果与原项目完全一致;支持设置Http服务器(需要Qt6.4及以上),运行ApiServer即可启动本地Http服务器

需求和依赖

本项目需要以下库:

  • Qt >= 5.12

使用说明

引用动态库文件

在CMakeLists.txt文件中加上

# 指定第三方库的路径
set(LIBRARY_DIR "${PROJECT_SOURCE_DIR}/QCloudMusicApi")

# 添加头文件路径
include_directories(${LIBRARY_DIR}/include)

# 添加库文件路径
link_directories(${LIBRARY_DIR}/bin)

使用ApiHelper类

该类实现了API的cookie管理

代码中包含头文件apihelper.h

#include "apihelper.h"

通过对应方法字符串调用

ApiHelper helper;
qDebug() << helper.invoke("lyric", { { "id", 1408586353 } });

直接调用API的方法

ApiHelper helper;
qDebug() << helper.invoke(&NeteaseCloudMusicApi::lyric, { { "id", 1408586353 } });

调用ApiHelper::set_cookie设置cookie,支持QVariantMap和QString

使用NeteaseCloudMusicApi类

若无需保存cookie,可直接使用该类

代码中包含头文件module.h

#include "module.h"

可直接调用类函数

NeteaseCloudMusicApi api;
qDebug() << api.lyric({ { "id", 1408586353 } });

也可以通过Qt的反射调用

NeteaseCloudMusicApi api;
QVariantMap ret;
QMetaObject::invokeMethod(&api, "lyric"
                              , Qt::DirectConnection
                              , Q_RETURN_ARG(QVariantMap, ret)
                              , Q_ARG(QVariantMap, QVariantMap({ {"id", 1408586353} }));
qDebug() << ret;

在项目中引用CMake项目

在CMakeLists.txt文件中加上

add_subdirectory(QCloudMusicApi)

add_executable(YourProjectName
    ./QCloudMusicApi/QCloudMusicApi/module.h
  main.cpp
)

target_compile_definitions(YourProjectName PRIVATE QCLOUDMUSICAPI_LIBRARY)
# 添加需要链接的库
target_link_libraries(YourProjectName  QCloudMusicApi)

C++代码中加上

#include "QCloudMusicApi/QCloudMusicApi/module.h"

手动编译

手动安装好Qt库后

git clone https://github.com/s12mmm3/QCloudMusicApi.git
cmake -B build
cmake --build build -j

License

The MIT License (MIT)

qcloudmusicapi's People

Contributors

ahdbshsnsndnnm avatar s12mmm3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

qcloudmusicapi's Issues

cookie api内保存

api内部可以尝试做一个session保存cookie,用户保存的话还得手动管理,类似于pyncm中的

无法登录

使用login_cellphone,无论账号密码是否正确都返回

{
    "body": "",
    "cookie": null,
    "status": 200
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.