Skip to content

Commit 084dc1d

Browse files
authored
Merge pull request #35 from elsagranger/dev2
Fix cookie and support to use base64 as file in upload to cloud
2 parents 2e25539 + c1e8afd commit 084dc1d

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

QCloudMusicApi/module.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <QJsonDocument>
1+
#include <QJsonDocument>
22
#include <QJsonArray>
33
#include <QJsonObject>
44
#include <QNetworkRequest>
@@ -779,7 +779,7 @@ QVariantMap Api::cloud_match(QVariantMap query) {
779779
// 云盘上传
780780
QVariantMap Api::cloud(QVariantMap query) {
781781
QString ext = "mp3";
782-
if (query["songFile"].toMap()["name"].toString().indexOf("flac") > -1) {
782+
if (query["songFile"].toMap()["name"].toString().toLower().indexOf("flac") > -1) {
783783
ext = "flac";
784784
}
785785
QString filename = query["songFile"].toMap()["name"].toString()
@@ -802,6 +802,13 @@ QVariantMap Api::cloud(QVariantMap query) {
802802
}
803803
};
804804
}
805+
806+
if (query.contains("dataAsBase64")) {
807+
auto songFile = query["songFile"].toMap();
808+
songFile["data"] = QByteArray::fromBase64(songFile["data"].toByteArray());
809+
query["songFile"] = songFile;
810+
}
811+
805812
if (!query["songFile"].toMap().contains("md5")) {
806813
auto songFile = query["songFile"].toMap();
807814
auto data = songFile["data"].toByteArray();
@@ -831,6 +838,16 @@ QVariantMap Api::cloud(QVariantMap query) {
831838
QString album = "";
832839
QString songName = "";
833840

841+
if (query.contains("artist")) {
842+
artist = query["artist"].toString();
843+
}
844+
if (query.contains("album")) {
845+
album = query["album"].toString();
846+
}
847+
if (query.contains("songName")) {
848+
songName = query["songName"].toString();
849+
}
850+
834851
const auto tokenRes = request(
835852
POST,
836853
"https://music.163.com/weapi/nos/token/alloc",

QCloudMusicApi/plugins.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Plugins::Plugins(QObject *parent)
1919
QVariantMap Plugins::songUpload(QVariantMap query)
2020
{
2121
QString ext = "mp3";
22-
if (query["songFile"].toMap()["name"].toString().indexOf("flac") > -1) {
22+
if (query["songFile"].toMap()["name"].toString().toLower().indexOf("flac") > -1) {
2323
ext = "flac";
2424
}
2525
QString filename = query["songFile"].toMap()["name"].toString()
@@ -65,7 +65,7 @@ QVariantMap Plugins::songUpload(QVariantMap query)
6565
{ "Content-Type", "audio/mpeg" },
6666
{ "Content-Length", query["songFile"].toMap()["size"] },
6767
},
68-
query["imgFile"].toMap()["data"].toByteArray());
68+
query["songFile"].toMap()["data"].toByteArray());
6969
reply->manager()->deleteLater();
7070

7171
return tokenRes;

0 commit comments

Comments
 (0)