Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit 2146179

Browse files
committed
fix mobile
1 parent 5828e6e commit 2146179

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

routes/index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,30 @@ router.post('/eapi/song/enhance/player/url', function(req, res, next) {
7070
function(detail, callback) {
7171
var songName = utils.netease.getSongName(detail);
7272
var artist = utils.netease.getArtistName(detail);
73-
utils.kugou.search(songName, artist, function(err, hash, bitrate) {
73+
utils.kugou.search(songName, artist, function(err, hash, bitrate, filesize) {
7474
if (err) {
7575
console.error(err);
7676
} else {
77-
callback(null, hash, bitrate);
77+
callback(null, hash, bitrate, filesize);
7878
}
7979
});
8080
},
81-
function(hash, bitrate, callback) {
81+
function(hash, bitrate, filesize, callback) {
8282
utils.kugou.getUrl(hash, function(err, url) {
8383
if (err) {
8484
console.error(err);
8585
} else {
86-
callback(null, url, bitrate);
86+
callback(null, url, bitrate, filesize);
8787
}
8888
});
8989
}
90-
], function(err, url, bitrate) {
90+
], function(err, url, bitrate, filesize) {
9191
if(err) {
9292
console.error(err);
9393
res.status = 500;
9494
res.send();
9595
}else{
96-
res.defaultBody = utils.netease.modifyPlayerApiCustom(url, bitrate, res.defaultBody);
96+
res.defaultBody = utils.netease.modifyPlayerApiCustom(url, bitrate, filesize, res.defaultBody);
9797
next();
9898
}
9999
});
@@ -122,30 +122,30 @@ router.post('/eapi/song/enhance/download/url', function(req, res, next) {
122122
function(detail, callback) {
123123
var songName = utils.netease.getSongName(detail);
124124
var artist = utils.netease.getArtistName(detail);
125-
utils.kugou.search(songName, artist, function(err, hash, bitrate) {
125+
utils.kugou.search(songName, artist, function(err, hash, bitrate, filesize) {
126126
if (err) {
127127
console.error(err);
128128
} else {
129-
callback(null, hash, bitrate);
129+
callback(null, hash, bitrate, filesize);
130130
}
131131
});
132132
},
133-
function(hash, bitrate, callback) {
133+
function(hash, bitrate, filesize, callback) {
134134
utils.kugou.getUrl(hash, function(err, url) {
135135
if (err) {
136136
console.error(err);
137137
} else {
138-
callback(null, url, bitrate);
138+
callback(null, url, bitrate, filesize);
139139
}
140140
});
141141
}
142-
], function(err, url, bitrate) {
142+
], function(err, url, bitrate, filesize) {
143143
if(err) {
144144
console.error(err);
145145
res.status = 500;
146146
res.send();
147147
}else{
148-
res.defaultBody = utils.netease.modifyDownloadApiCustom(url, bitrate, res.defaultBody);
148+
res.defaultBody = utils.netease.modifyDownloadApiCustom(url, bitrate, filesize, res.defaultBody);
149149
next();
150150
}
151151
});

utils/kugou/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ kugou.prototype.search = function(name, artist, callback) {
2222
if (!!hash320.length) {
2323
var hash = hash320;
2424
var bitrate = 320000;
25+
var filesize = data['data']['info'][0]['320filesize'];
2526
} else {
2627
var hash = hash128;
2728
var bitrate = 128000;
29+
var filesize = data['data']['info'][0]['filesize'];
2830
}
29-
callback(null, hash, bitrate);
31+
callback(null, hash, bitrate, filesize);
3032
} else {
3133
callback('No resource found on kugou.');
3234
}

utils/netease/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ netease.prototype.modifyDetailApi = function(body) {
9797
.replace(/\"subp\":\d+/g, '"subp":1');
9898
}
9999

100-
netease.prototype.modifyPlayerApiCustom = function(newUrl, bitrate, body) {
100+
netease.prototype.modifyPlayerApiCustom = function(newUrl, bitrate, filesize, body) {
101101
console.log("Player API Injected".green);
102-
// console.log(body);
103102

104103
var _this = this;
105104

@@ -110,6 +109,9 @@ netease.prototype.modifyPlayerApiCustom = function(newUrl, bitrate, body) {
110109
body["data"][0]["url"] = newUrl;
111110
body["data"][0]["br"] = bitrate;
112111
body["data"][0]["code"] = "200";
112+
// body["data"][0]["md5"] = 'efba483eb717cc872436075748bcfcf8';
113+
body["data"][0]["size"] = filesize;
114+
body["data"][0]["type"] = "mp3";
113115

114116
return JSON.stringify(body);
115117
}

0 commit comments

Comments
 (0)