Skip to content

Commit

Permalink
feat:增加部分接口
Browse files Browse the repository at this point in the history
  • Loading branch information
overwriter committed Jan 12, 2024
1 parent 5c64557 commit 9c04fbe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
39 changes: 39 additions & 0 deletions QCloudMusicApi/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,45 @@ APICPP(cellphone_existence_check) {
);
}

// 歌曲可用性
APICPP(check_music) {
const QVariantMap data {
{ "ids", QStringList { query["id"].toString() } },
{ "br", query.value("br", 999000) }
};
QVariantMap result = request(
POST,
"https://music.163.com/weapi/song/enhance/player/url",
data,
{
{ "crypto", "weapi" },
_PARAM
}
);
auto playable = false;
if(result["body"].toMap()["code"].toInt() == 200) {
if(result["body"].toMap()["data"].toList()[0].toMap()["code"].toInt() == 200) {
playable = true;
}
}
if(playable) {
result["body"] = QVariantMap {
{ "code", 200 },
{ "success", true },
{ "message", "ok" }
};
return result;
}
else {
result["body"] = QVariantMap {
{ "code", 200 },
{ "success", false },
{ "message", "亲爱的,暂无版权" }
};
return result;
}
}

// 搜索
APICPP(cloudsearch) {
const QVariantMap data {
Expand Down
3 changes: 3 additions & 0 deletions QCloudMusicApi/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi: public QObject {
// 检测手机号码是否已注册
APIH(cellphone_existence_check)

// 歌曲可用性
APIH(check_music)

// 搜索
APIH(cloudsearch)

Expand Down
4 changes: 2 additions & 2 deletions QCloudMusicApi/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Request {
QString chooseUserAgent(QString ua = "") {
const QVariantMap userAgentList {
{
"mobile",
QStringLiteral("mobile"),
QStringList {
// iOS 13.5.1 14.0 beta with safari
QStringLiteral(R"(Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1)"),
Expand All @@ -44,7 +44,7 @@ QString chooseUserAgent(QString ua = "") {
}
},
{
"pc",
QStringLiteral("pc"),
QStringList {
// macOS 10.15.6 Firefox / Chrome / Safari
QStringLiteral(R"(Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0)"),
Expand Down

0 comments on commit 9c04fbe

Please sign in to comment.