diff --git a/QCloudMusicApi/module.cpp b/QCloudMusicApi/module.cpp index 5ea18e8..8dd2296 100644 --- a/QCloudMusicApi/module.cpp +++ b/QCloudMusicApi/module.cpp @@ -1722,6 +1722,61 @@ QVariantMap Api::likelist(QVariantMap query) { ); } +// 听歌足迹 - 本周/本月收听时长 +QVariantMap Api::listen_data_realtime_report(QVariantMap query) { + const QVariantMap data{ + { "type", query.value("type", "week") }, //周 week 月 month + }; + return request( + "/api/content/activity/listen/data/realtime/report", + data, + Option::createOption(query) + ); +} + +// 听歌足迹 - 周/月/年收听报告 +QVariantMap Api::listen_data_report(QVariantMap query) { + QVariantMap data{ + { "type", query.value("type", "week") }, //周 week 月 month 年 year + }; + if (query.contains("endTime")) data["endTime"] = query["endTime"]; // 不填就是本周/月的 + return request( + "/api/content/activity/listen/data/report", + data, + Option::createOption(query) + ); +} + +// 听歌足迹 - 今日收听 +QVariantMap Api::listen_data_today_song(QVariantMap query) { + QVariantMap data{}; + return request( + "/api/content/activity/listen/data/today/song/play/rank", + data, + Option::createOption(query) + ); +} + +// 听歌足迹 - 总收听时长 +QVariantMap Api::listen_data_total(QVariantMap query) { + QVariantMap data{}; + return request( + "/api/content/activity/listen/data/total", + data, + Option::createOption(query) + ); +} + +// 听歌足迹 - 年度听歌足迹 +QVariantMap Api::listen_data_year_report(QVariantMap query) { + QVariantMap data{}; + return request( + "/api/content/activity/listen/data/year/report", + data, + Option::createOption(query) + ); +} + // 一起听 接受邀请 QVariantMap Api::listentogether_accept(QVariantMap query) { const QVariantMap data{ @@ -2550,6 +2605,79 @@ QVariantMap Api::playlist_hot(QVariantMap query) { ); } +// 歌单导入 - 元数据/文字/链接导入 +QVariantMap Api::playlist_import_name_task_create(QVariantMap query) { + QVariantMap data{ + { "importStarPlaylist", query.value("importStarPlaylist", false) }, + }; + + if (query.contains("local")) { + // 元数据导入 + auto local = QJsonDocument::fromJson(query["local"].toString().toUtf8()).toVariant().toList(); + auto multiSongs = QJsonDocument::fromVariant([=](){ + QVariantList result; + for (auto e: local) result.push_back(QVariantMap{ + { "songName", e.toMap()["name"] }, + { "artistName", e.toMap()["artist"] }, + { "albumName", e.toMap()["album"] }, + }); + return result; + }()).toJson(); + data["multiSongs"] = multiSongs; + } + else { + auto playlistName = query.value("playlistName", QObject::tr("导入音乐 ") + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); // 歌单名称 + QString songs; + if (query.contains("text")) { + // 文字导入 + songs = QJsonDocument::fromVariant(QVariantList{ + QVariantMap{ + { "name", playlistName }, + { "type", "" }, + { "url", "rpc://playlist/import?text=" + query["text"].toString() }, +} + }).toJson(); + } + + if (query.contains("link")) { + // 链接导入 + auto link = QJsonDocument::fromJson(query["link"].toString().toUtf8()).toVariant().toList(); + songs = QJsonDocument::fromVariant([=](){ + QVariantList result; + for (auto e: link) result.push_back(QVariantMap{ + { "name", playlistName }, + { "type", "" }, + { "url", e.toString() }, + }); + return result; + }()).toJson(); + } + data = Index::mergeMap(data, { + { "playlistName", playlistName }, + { "createBusinessCode", QVariant() }, + { "extParam", QVariant() }, + { "taskIdForLog", "" }, + { "songs", songs }, + }); + } + return request( + "/api/playlist/import/name/task/create", + data, + Option::createOption(query) + ); +} + +// 歌单导入 - 任务状态 +QVariantMap Api::playlist_import_task_status(QVariantMap query) { + return request( + "/api/playlist/import/task/status/v2", + { + { "taskIds", QJsonDocument::fromVariant(QVariantList{ query["id"] }).toJson() }, + }, + Option::createOption(query) + ); +} + // 获取点赞过的视频 QVariantMap Api::playlist_mylike(QVariantMap query) { const QVariantMap data{ @@ -4249,6 +4377,18 @@ QVariantMap Api::user_level(QVariantMap query) { ); } +// 用户徽章 +QVariantMap Api::user_medal(QVariantMap query) { + const QVariantMap data{ + { "uid", query["uid"] }, + }; + return request( + "/api/medal/user/page", + data, + Option::createOption(query) + ); +} + // 用户是否互相关注 QVariantMap Api::user_mutualfollow_get(QVariantMap query) { const QVariantMap data{ @@ -4304,6 +4444,51 @@ QVariantMap Api::user_replacephone(QVariantMap query) { ); } +// 用户状态 - 编辑 +QVariantMap Api::user_social_status_edit(QVariantMap query) { + return request( + "/api/social/user/status/edit", + { + { "content", QJsonDocument::fromVariant(QVariantMap{ + { "type", query["type"] }, + { "iconUrl", query["iconUrl"] }, + { "content", query["content"] }, + { "actionUrl", query["actionUrl"] }, + }).toJson() }, + }, + Option::createOption(query) + ); +} + +// 用户状态 - 相同状态的用户 +QVariantMap Api::user_social_status_rcmd(QVariantMap query) { + return request( + "/api/social/user/status/rcmd", + {}, + Option::createOption(query) + ); +} + +// 用户状态 - 相同状态的用户 +QVariantMap Api::user_social_status_support(QVariantMap query) { + return request( + "/api/social/user/status/support", + {}, + Option::createOption(query) + ); +} + +// 用户状态 +QVariantMap Api::user_social_status(QVariantMap query) { + return request( + "/api/social/user/status", + { + { "visitorId", query["uid"] }, + }, + Option::createOption(query) + ); +} + // 收藏计数 QVariantMap Api::user_subcount(QVariantMap query) { return request( diff --git a/QCloudMusicApi/module.h b/QCloudMusicApi/module.h index bb951a8..fb20926 100644 --- a/QCloudMusicApi/module.h +++ b/QCloudMusicApi/module.h @@ -387,6 +387,21 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi : public QObject { // 喜欢音乐列表 Q_INVOKABLE QVariantMap likelist(QVariantMap); + // 听歌足迹 - 本周/本月收听时长 + Q_INVOKABLE QVariantMap listen_data_realtime_report(QVariantMap); + + // 听歌足迹 - 周/月/年收听报告 + Q_INVOKABLE QVariantMap listen_data_report(QVariantMap); + + // 听歌足迹 - 今日收听 + Q_INVOKABLE QVariantMap listen_data_today_song(QVariantMap); + + // 听歌足迹 - 总收听时长 + Q_INVOKABLE QVariantMap listen_data_total(QVariantMap); + + // 听歌足迹 - 年度听歌足迹 + Q_INVOKABLE QVariantMap listen_data_year_report(QVariantMap); + // 一起听 接受邀请 Q_INVOKABLE QVariantMap listentogether_accept(QVariantMap); @@ -558,6 +573,12 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi : public QObject { // 热门歌单分类 Q_INVOKABLE QVariantMap playlist_hot(QVariantMap); + // 歌单导入 - 元数据/文字/链接导入 + Q_INVOKABLE QVariantMap playlist_import_name_task_create(QVariantMap); + + // 歌单导入 - 任务状态 + Q_INVOKABLE QVariantMap playlist_import_task_status(QVariantMap); + // 获取点赞过的视频 Q_INVOKABLE QVariantMap playlist_mylike(QVariantMap); @@ -909,6 +930,9 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi : public QObject { // 获取用户等级信息 Q_INVOKABLE QVariantMap user_level(QVariantMap); + // 用户徽章 + Q_INVOKABLE QVariantMap user_medal(QVariantMap); + // 用户是否互相关注 Q_INVOKABLE QVariantMap user_mutualfollow_get(QVariantMap); @@ -921,6 +945,18 @@ class QCLOUDMUSICAPI_EXPORT NeteaseCloudMusicApi : public QObject { // 用户绑定手机 Q_INVOKABLE QVariantMap user_replacephone(QVariantMap); + // 用户状态 - 编辑 + Q_INVOKABLE QVariantMap user_social_status_edit(QVariantMap); + + // 用户状态 - 相同状态的用户 + Q_INVOKABLE QVariantMap user_social_status_rcmd(QVariantMap); + + // 用户状态 - 支持设置的状态 + Q_INVOKABLE QVariantMap user_social_status_support(QVariantMap); + + // 用户状态 + Q_INVOKABLE QVariantMap user_social_status(QVariantMap); + // 收藏计数 Q_INVOKABLE QVariantMap user_subcount(QVariantMap); diff --git a/QCloudMusicApi/util/option.cpp b/QCloudMusicApi/util/option.cpp index 189640a..c0aa312 100644 --- a/QCloudMusicApi/util/option.cpp +++ b/QCloudMusicApi/util/option.cpp @@ -3,12 +3,8 @@ using namespace QCloudMusicApi; QVariantMap Option::createOption(QVariantMap query, QString crypto) { - return { - { "crypto", query.value("crypto", crypto) }, - { "cookie", query["cookie"] }, - { "ua", query.value("ua", "") }, - { "proxy", query["proxy"] }, - { "realIP", query["realIP"] }, - { "e_r", query.value("e_r") }, - }; + QVariantMap result; + auto func = [&](QString key) { if (query.contains(key)) result[key] = query[key]; }; + for (auto i: { "crypto", "cookie", "ua", "proxy", "realIP", "e_r" }) func(i); + return result; } diff --git a/QCloudMusicApi/util/request.cpp b/QCloudMusicApi/util/request.cpp index 342c378..2e03b53 100644 --- a/QCloudMusicApi/util/request.cpp +++ b/QCloudMusicApi/util/request.cpp @@ -37,7 +37,7 @@ const QVariantMap osMap{ { "osver", "14" }, } }, { "iphone", QVariantMap { - { "os", "iOS" }, + { "os", "iPhone OS" }, { "appver", "9.0.90" }, { "osver", "16.2" }, } }, @@ -136,7 +136,7 @@ QVariantMap Request::createRequest( QString url = ""; QVariantMap encryptData; - auto crypto = options["crypto"]; + auto crypto = options.value("crypto", ""); auto csrfToken = cookie.value("__csrf", ""); if (crypto == "") { diff --git a/Test/config.json b/Test/config.json index 8f5ecfe..e4d4a00 100644 --- a/Test/config.json +++ b/Test/config.json @@ -538,5 +538,17 @@ }, "user_mutualfollow_get": { "uid": "79248480" + }, + "user_medal": { + "uid": "79248480" + }, + "user_social_status": { + "uid": "79248480" + }, + "playlist_import_name_task_create": { + "link": "[\"https://i.y.qq.com/n2/m/share/details/taoge.html?id=7716341988&hosteuin=\",\"https://i.y.qq.com/n2/m/share/details/taoge.html?id=8010042041&hosteuin=\"]" + }, + "playlist_import_task_status": { + "id": "124050147" } } \ No newline at end of file