diff --git a/QCloudMusicApi/module.cpp b/QCloudMusicApi/module.cpp index 392ff83..f9a51dd 100644 --- a/QCloudMusicApi/module.cpp +++ b/QCloudMusicApi/module.cpp @@ -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( diff --git a/QCloudMusicApi/module.h b/QCloudMusicApi/module.h index e71261d..5f5edba 100644 --- a/QCloudMusicApi/module.h +++ b/QCloudMusicApi/module.h @@ -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); diff --git a/QCloudMusicApi/util/config.h b/QCloudMusicApi/util/config.h index 3743af9..b4e6f98 100644 --- a/QCloudMusicApi/util/config.h +++ b/QCloudMusicApi/util/config.h @@ -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_" },