Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:s12mmm3/QCloudMusicApi into openssl-…
Browse files Browse the repository at this point in the history
…cmake
  • Loading branch information
overwriter committed Jan 21, 2024
2 parents b13b3c2 + e71c7ac commit 5ca7cc7
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 58 deletions.
6 changes: 3 additions & 3 deletions ApiServer/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "../QCloudMusicApi/module.h"

#include <QCoreApplication>
#include <QCoreApplication>
#include <QHttpServer>
#include <QJsonDocument>
#include <QMetaMethod>
#include <QMetaObject>
#include <QUrlQuery>
#include <QtConcurrent>

#include "../QCloudMusicApi/module.h"

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Expand Down
8 changes: 4 additions & 4 deletions CApi/capi.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "capi.h"
#include "../QCloudMusicApi/module.h"

#include <QCoreApplication>
#include <QCoreApplication>
#include <QSslSocket>
#include <QJsonDocument>
#include <QMetaMethod>
#include <QMetaObject>

#include "capi.h"
#include "../QCloudMusicApi/module.h"

CAPI_EXPORT char* invoke(char* funName, char* value) {
QString result;
int argc = 1;
Expand Down
212 changes: 206 additions & 6 deletions QCloudMusicApi/module.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <iostream>
#include <QJsonDocument>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QNetworkRequest>
Expand All @@ -9,7 +8,8 @@
#include <QRegularExpression>
#include <QRandomGenerator>

#include "request.h"
#include "util/config.h"
#include "util/request.h"
#include "module.h"

//入参与返回值类型为QVariantMap
Expand All @@ -22,9 +22,10 @@ const QVariantMap NeteaseCloudMusicApi::FUNCNAME(QVariantMap query)
{ "proxy", query["proxy"] }, \
{ "realIP", query["realIP"] } \

const static auto request = Request::createRequest;
const static auto POST = QNetworkAccessManager::PostOperation;
const static auto GET = QNetworkAccessManager::GetOperation;
const static auto &request = Request::createRequest;
const static auto &POST = QNetworkAccessManager::PostOperation;
const static auto &GET = QNetworkAccessManager::GetOperation;
const static auto &resourceTypeMap = Config::resourceTypeMap;

// 初始化名字
APICPP(activate_init_profile) {
Expand Down Expand Up @@ -663,6 +664,28 @@ APICPP(check_music) {
}
}

// 云盘歌曲信息匹配纠正
APICPP(cloud_match) {
QVariantMap cookie = query["cookie"].toMap();
cookie["os"] = "ios";
cookie["appver"] = "8.10.90";
query["cookie"] = cookie;
const QVariantMap data {
{ "userId", query["uid"] },
{ "songId", query["sid"] },
{ "adjustSongId", query["asid"] }
};
return request(
POST,
"https://music.163.com/api/cloud/user/song/match",
data,
{
{ "crypto", "weapi" },
_PARAM
}
);
}

// 搜索
APICPP(cloudsearch) {
const QVariantMap data {
Expand Down Expand Up @@ -746,6 +769,102 @@ APICPP(comment_event) {
);
}

// 楼层评论
APICPP(comment_floor) {
query["type"] = resourceTypeMap[query["type"].toString()];
const QVariantMap data {
{ "parentCommentId", query["parentCommentId"] },
{ "threadId", query["type"].toString() + query["id"].toString() },
{ "time", query.value("time", -1) },
{ "limit", query.value("limit", 20) }
};
return request(
POST,
"https://music.163.com/api/resource/comment/floor/get",
data,
{
{ "crypto", "weapi" },
_PARAM
}
);
}

// 热门评论
APICPP(comment_hot) {
QVariantMap cookie = query["cookie"].toMap();
cookie["os"] = "pc";
query["cookie"] = cookie;
query["type"] = resourceTypeMap[query["type"].toString()];
const QVariantMap data {
{ "rid", query["id"] },
{ "limit", query.value("limit", 20) },
{ "offset", query.value("offset", 0) },
{ "beforeTime", query.value("before", 0) }
};
return request(
POST,
"https://music.163.com/weapi/v1/resource/hotcomments/" + query["type"].toString() + query["id"].toString(),
data,
{
{ "crypto", "weapi" },
_PARAM
}
);
}

// 评论抱一抱列表
APICPP(comment_hug_list) {
QVariantMap cookie = query["cookie"].toMap();
cookie["os"] = "ios";
cookie["appver"] = "8.10.90";
query["cookie"] = cookie;
query["type"] = resourceTypeMap[query.value("type", "0").toString()];
const QString threadId = query["type"].toString() + query["sid"].toString();
const QVariantMap data {
{ "targetUserId", query["uid"] },
{ "commentId", query["cid"] },
{ "cursor", query.value("cursor", "-1") },
{ "threadId", threadId },
{ "pageNo", query.value("page", 1) },
{ "idCursor", query.value("idCursor", -1) },
{ "pageSize", query.value("pageSize", 100) }
};
return request(
POST,
"https://music.163.com/api/v2/resource/comments/hug/list",
data,
{
{ "crypto", "api" },
_PARAM
}
);
}

// 点赞与取消点赞评论
APICPP(comment_like) {
QVariantMap cookie = query["cookie"].toMap();
cookie["os"] = "pc";
query["cookie"] = cookie;
query["t"] = query["t"].toInt() == 1 ? "like" : "unlike";
query["type"] = resourceTypeMap[query["type"].toString()];
QVariantMap data {
{ "threadId", query["type"].toString() + query["sid"].toString() },
{ "commentId", query["cid"] }
};
if(query["type"].toString() == "A_EV_2_") {
data["threadId"] = query["threadId"];
}
return request(
POST,
"https://music.163.com/weapi/v1/comment/" + query["t"].toString(),
data,
{
{ "crypto", "weapi" },
_PARAM
}
);
}

// 歌曲评论
APICPP(comment_music) {
QVariantMap cookie = query["cookie"].toMap();
Expand Down Expand Up @@ -790,6 +909,53 @@ APICPP(comment_mv) {
);
}

// 新版评论接口
APICPP(comment_new) {
QVariantMap cookie = query["cookie"].toMap();
cookie["os"] = "pc";
query["cookie"] = cookie;
query["type"] = resourceTypeMap[query["type"].toString()];
const QString threadId = query["type"].toString() + query["id"].toString();
const int pageSize = query.value("pageSize", 20).toInt();
const int pageNo = query.value("pageNo", 1).toInt();
int sortType = query.value("sortType", 99).toInt();
if(sortType == 1) {
sortType = 99;
}
QString cursor = "";
switch (sortType) {
case 99:
cursor = QString::number((pageNo - 1) * pageSize);
break;
case 2:
cursor = "normalHot#" + QString::number((pageNo - 1) * pageSize);
break;
case 3:
cursor = query.value("cursor", "0").toString();
break;
default:
break;
}
const QVariantMap data {
{ "threadId", threadId },
{ "pageNo", pageNo },
{ "showInner", query.value("showInner", true) },
{ "pageSize", pageSize },
{ "cursor", cursor },
{ "sortType", sortType } //99:按推荐排序,2:按热度排序,3:按时间排序
};
return request(
POST,
"https://music.163.com/api/v2/resource/comments",
data,
{
{ "crypto", "eapi" },
_PARAM,
{ "url", "/api/v2/resource/comments" }
}
);
}

// 歌单评论
APICPP(comment_playlist) {
QVariantMap cookie = query["cookie"].toMap();
Expand Down Expand Up @@ -834,6 +1000,40 @@ APICPP(comment_video) {
);
}

// 发送与删除评论
APICPP(comment) {
QVariantMap cookie = query["cookie"].toMap();
cookie["os"] = "android";
query["cookie"] = cookie;
query["t"] = QMap<int, QString> {
{ 1, "add" },
{ 0, "delete" },
{ 2, "reply" }
}[query["t"].toInt()];
query["type"] = resourceTypeMap[query["type"].toString()];
QVariantMap data {
{ "threadId", query["type"].toString() + query["id"].toString() }
};
if(query["type"].toString() == "A_EV_2_") {
data["threadId"] = query["threadId"];
}
if(query["t"].toString() == "add") data["content"] = query["content"];
else if(query["t"].toString() == "delete") data["commentId"] = query["commentId"];
else if(query["t"].toString() == "reply") {
data["commentId"] = query["commentId"];
data["content"] = query["content"];
}
return request(
POST,
"https://music.163.com/weapi/resource/comments/" + query["t"].toString(),
data,
{
{ "crypto", "weapi" },
_PARAM
}
);
}

// 国家编码列表
APICPP(countries_code_list) {
const QVariantMap data { };
Expand Down
27 changes: 24 additions & 3 deletions QCloudMusicApi/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#define MODULE_H

#include <QVariantMap>
#include <QObject>
#include <QByteArray>
#include <QtCore/qglobal.h>

#if defined(QCLOUDMUSICAPI_LIBRARY)
# define QCLOUDMUSICAPI_EXPORT Q_DECL_EXPORT
Expand Down Expand Up @@ -137,6 +134,12 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi: public QObject {
// 歌曲可用性
APIH(check_music)

// 云盘歌曲信息匹配纠正
APIH(cloud_match)

// 云盘上传
// APIH(cloud)

// 搜索
APIH(cloudsearch)

Expand All @@ -149,18 +152,36 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi: public QObject {
// 获取动态评论
APIH(comment_event)

// 楼层评论
APIH(comment_floor)

// 热门评论
APIH(comment_hot)

// 评论抱一抱列表
APIH(comment_hug_list)

// 点赞与取消点赞评论
APIH(comment_like)

// 歌曲评论
APIH(comment_music)

// MV评论
APIH(comment_mv)

// 新版评论接口
APIH(comment_new)

// 歌单评论
APIH(comment_playlist)

// 视频评论
APIH(comment_video)

// 发送与删除评论
APIH(comment)

// 国家编码列表
APIH(countries_code_list)

Expand Down
5 changes: 2 additions & 3 deletions QCloudMusicApi/util/config.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#ifndef CONFIG_H
#define CONFIG_H

#include <QObject>
#include <QVariantMap>

namespace Config {

const static QString anonymous_token = QStringLiteral("de91e1f8119d32e01cc73efcb82c0a30c9137e8d4f88dbf5e3d7bf3f28998f21add2bc8204eeee5e56c0bbb8743574b46ca2c10c35dc172199bef9bf4d60ecdeab066bb4dc737d1c3324751bcc9aaf44c3061cd18d77b7a0");
const static QVariantMap resourceTypeMap {
static QString anonymous_token = QStringLiteral("de91e1f8119d32e01cc73efcb82c0a30c9137e8d4f88dbf5e3d7bf3f28998f21add2bc8204eeee5e56c0bbb8743574b46ca2c10c35dc172199bef9bf4d60ecdeab066bb4dc737d1c3324751bcc9aaf44c3061cd18d77b7a0");
const static QMap<QString, QString> resourceTypeMap {
{ "0", "R_SO_4_" },
{ "1", "R_MV_5_" },
{ "2", "A_PL_0_" },
Expand Down
1 change: 0 additions & 1 deletion QCloudMusicApi/util/crypto.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef CRYPTO_H
#define CRYPTO_H

#include <iostream>
#include <QByteArray>
#include <QObject>
#include <QVariantMap>
Expand Down
1 change: 1 addition & 0 deletions QCloudMusicApi/util/index.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef INDEX_H
#define INDEX_H

#include <QNetworkCookie>
#include <QVariantMap>

Expand Down
Loading

0 comments on commit 5ca7cc7

Please sign in to comment.