Skip to content

Commit

Permalink
feat:增加部分接口
Browse files Browse the repository at this point in the history
  • Loading branch information
overwriter committed Nov 24, 2023
1 parent 55ba1df commit 76477d2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
53 changes: 53 additions & 0 deletions QCloudMusicApi/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,59 @@ const QVariantMap NeteaseCloudMusicApi::login_qr_create(QVariantMap query) {
return result;
}

// 登录刷新
const QVariantMap NeteaseCloudMusicApi::login_refresh(QVariantMap query) {
QVariantMap result = createRequest(
QNetworkAccessManager::PostOperation,
"https://music.163.com/weapi/login/token/refresh",
{},
QVariantMap {
{ "crypto", "weapi" },
{ "ua", "pc" },
{ "cookie", query["cookie"] },
{ "proxy", query["proxy"] },
{ "realIP", query["realIP"] }
}
);
if(result["body"].toMap()["code"].toInt() == 200) {
auto body = result["body"].toMap();
body["cookie"] = result["cookie"];
result = QVariantMap {
{ "status", 200 },
{ "body", body },
{ "cookie", result["cookie"] }
};
}
return result;
}

// 登录状态
const QVariantMap NeteaseCloudMusicApi::login_status(QVariantMap query) {
QVariantMap result = createRequest(
QNetworkAccessManager::PostOperation,
"https://music.163.com/weapi/w/nuser/account/get",
{},
QVariantMap {
{ "crypto", "weapi" },
{ "cookie", query["cookie"] },
{ "proxy", query["proxy"] },
{ "realIP", query["realIP"] }
}
);
if(result["body"].toMap()["code"].toInt() == 200) {
auto body = result["body"].toMap();
body["cookie"] = result["cookie"];
result = QVariantMap {
{ "status", 200 },
{ "body", {
{ "data", result["body"] }
} },
{ "cookie", result["cookie"] }
};
}
return result;
}

// 退出登录
const QVariantMap NeteaseCloudMusicApi::logout(QVariantMap query) {
return createRequest(
Expand Down
6 changes: 6 additions & 0 deletions QCloudMusicApi/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi: public QObject {
// 二维码 key 生成接口
Q_INVOKABLE const QVariantMap login_qr_key(QVariantMap);

// 登录刷新
Q_INVOKABLE const QVariantMap login_refresh(QVariantMap);

// 登录状态
Q_INVOKABLE const QVariantMap login_status(QVariantMap);

// 退出登录
Q_INVOKABLE const QVariantMap logout(QVariantMap);

Expand Down
2 changes: 1 addition & 1 deletion QCloudMusicApi/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Config{

static QString anonymous_token = "de91e1f8119d32e01cc73efcb82c0a30c9137e8d4f88dbf5e3d7bf3f28998f21add2bc8204eeee5e56c0bbb8743574b46ca2c10c35dc172199bef9bf4d60ecdeab066bb4dc737d1c3324751bcc9aaf44c3061cd18d77b7a0";
static QVariantMap resourceTypeMap = {
static QVariantMap resourceTypeMap {
{ "0", "R_SO_4_" },
{ "1", "R_MV_5_" },
{ "2", "A_PL_0_" },
Expand Down

0 comments on commit 76477d2

Please sign in to comment.