mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-12-10 09:53:10 +00:00
update
This commit is contained in:
parent
8270c7318b
commit
af7e5aac89
@ -1,5 +1,5 @@
|
|||||||
# NeteaseCloudMusicApi
|
# NeteaseCloudMusicApi
|
||||||
|
<a href="https://www.npmjs.com/package/NeteaseCloudMusicApi"><img src="https://img.shields.io/npm/v/NeteaseCloudMusicApi.svg" alt="Version"></a>
|
||||||
一个调用网易云音乐 API 的 node 模块
|
一个调用网易云音乐 API 的 node 模块
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
108
build/app.js
108
build/app.js
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.api = undefined;
|
exports.api = undefined;
|
||||||
|
|
||||||
@ -16,57 +16,63 @@ var _util = require('./util');
|
|||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var api = {
|
var api = {
|
||||||
search: function search() {
|
search: function search() {
|
||||||
var name = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
|
var name = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
|
||||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||||
var limit = arguments.length <= 2 || arguments[2] === undefined ? 3 : arguments[2];
|
var limit = arguments.length <= 2 || arguments[2] === undefined ? 3 : arguments[2];
|
||||||
var offset = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
|
var offset = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
|
||||||
|
|
||||||
var option = (0, _util.deepCopy)(_config.globalOption);
|
var option = (0, _util.deepCopy)(_config.globalOption);
|
||||||
var url = _config.origin + '/api/search/suggest/web';
|
var url = _config.origin + '/api/search/suggest/web';
|
||||||
var form = {
|
var form = {
|
||||||
s: name,
|
s: name,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
type: 1,
|
type: 1,
|
||||||
offset: offset
|
offset: offset
|
||||||
};
|
};
|
||||||
var method = 'POST';
|
var method = 'POST';
|
||||||
Object.assign(option, { url: url, form: form, method: method });
|
Object.assign(option, { url: url, form: form, method: method });
|
||||||
(0, _request2.default)(option, function (error, response, body) {
|
(0, _request2.default)(option, function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
var info = JSON.parse(body);
|
var info = JSON.parse(body);
|
||||||
callback && callback(JSON.stringify(info, '', 2));
|
callback && callback(JSON.stringify(info, '', 2));
|
||||||
}
|
} else {
|
||||||
});
|
console.log(error);
|
||||||
},
|
}
|
||||||
song: function song(id) {
|
});
|
||||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
},
|
||||||
|
song: function song(id) {
|
||||||
|
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||||
|
|
||||||
var option = (0, _util.deepCopy)(_config.globalOption);
|
var option = (0, _util.deepCopy)(_config.globalOption);
|
||||||
var url = _config.origin + '/api/song/detail?ids=%5B' + id + '%5d';
|
var url = _config.origin + '/api/song/detail?ids=%5B' + id + '%5d';
|
||||||
var method = 'GET';
|
var method = 'GET';
|
||||||
Object.assign(option, { url: url, method: method });
|
Object.assign(option, { url: url, method: method });
|
||||||
(0, _request2.default)(option, function (error, response, body) {
|
(0, _request2.default)(option, function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
var info = JSON.parse(body);
|
var info = JSON.parse(body);
|
||||||
callback && callback(JSON.stringify(info, '', 2));
|
callback && callback(JSON.stringify(info, '', 2));
|
||||||
}
|
} else {
|
||||||
});
|
console.log(error);
|
||||||
},
|
}
|
||||||
lrc: function lrc(id) {
|
});
|
||||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
},
|
||||||
var lv = arguments.length <= 2 || arguments[2] === undefined ? -1 : arguments[2];
|
lrc: function lrc(id) {
|
||||||
|
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||||
|
var lv = arguments.length <= 2 || arguments[2] === undefined ? -1 : arguments[2];
|
||||||
|
|
||||||
var option = (0, _util.deepCopy)(_config.globalOption);
|
var option = (0, _util.deepCopy)(_config.globalOption);
|
||||||
var url = _config.origin + '/api/song/lyric?lv=' + lv + '&id=' + id;
|
var url = _config.origin + '/api/song/lyric?lv=' + lv + '&id=' + id;
|
||||||
var method = 'GET';
|
var method = 'GET';
|
||||||
Object.assign(option, { url: url, method: method });
|
Object.assign(option, { url: url, method: method });
|
||||||
(0, _request2.default)(option, function (error, response, body) {
|
(0, _request2.default)(option, function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
var info = JSON.parse(body);
|
var info = JSON.parse(body);
|
||||||
callback && callback(JSON.stringify(info, '', 2));
|
callback && callback(JSON.stringify(info, '', 2));
|
||||||
}
|
} else {
|
||||||
});
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
exports.api = api;
|
exports.api = api;
|
||||||
@ -1,16 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
var origin = 'http://music.163.com';
|
var origin = 'http://music.163.com';
|
||||||
|
|
||||||
var globalOption = {
|
var globalOption = {
|
||||||
headers: {
|
headers: {
|
||||||
'Origin': origin,
|
'Origin': origin,
|
||||||
'Referer': origin,
|
'Referer': origin,
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
}
|
},
|
||||||
|
proxy: false
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.origin = origin;
|
exports.origin = origin;
|
||||||
|
|||||||
48
npm-debug.log
Normal file
48
npm-debug.log
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
0 info it worked if it ends with ok
|
||||||
|
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
|
||||||
|
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
|
||||||
|
1 verbose cli 'run',
|
||||||
|
1 verbose cli 'test' ]
|
||||||
|
2 info using npm@3.9.5
|
||||||
|
3 info using node@v6.2.2
|
||||||
|
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
|
||||||
|
5 info lifecycle NeteaseCloudMusicApi@1.2.2~pretest: NeteaseCloudMusicApi@1.2.2
|
||||||
|
6 silly lifecycle NeteaseCloudMusicApi@1.2.2~pretest: no script for pretest, continuing
|
||||||
|
7 info lifecycle NeteaseCloudMusicApi@1.2.2~test: NeteaseCloudMusicApi@1.2.2
|
||||||
|
8 verbose lifecycle NeteaseCloudMusicApi@1.2.2~test: unsafe-perm in lifecycle true
|
||||||
|
9 verbose lifecycle NeteaseCloudMusicApi@1.2.2~test: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\ztf\Desktop\NeteaseCloudMusicApi\node_modules\.bin;C:\Program Files\nodejs;C:\Users\ztf\bin;C:\Program Files (x86)\Git\mingw32\bin;C:\Program Files (x86)\Git\usr\local\bin;C:\Program Files (x86)\Git\usr\bin;C:\Program Files (x86)\Git\usr\bin;C:\Program Files (x86)\Git\mingw32\bin;C:\Program Files (x86)\Git\usr\bin;C:\Users\ztf\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Users\ztf\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Java\jdk1.8.0_92\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\OpenVPN\bin;C:\Program Files\nodejs;C:\Program Files (x86)\Tesseract-OCR;C:\Users\ztf\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\ztf\AppData\Local\atom\bin;C:\ProgramData\chocolatey\bin;C:\Users\ztf\AppData\Local\Android\sdk\tools;C:\Users\ztf\AppData\Local\Android\sdk\platform-tools;C:\Users\ztf\AppData\Local\Microsoft\WindowsApps;C:\Python34;C:\Python34\Scripts;C:\Program Files (x86)\Git\cmd;D:\software\aria2\aria2c.exe;C:\Program Files (x86)\Git;C:\Users\ztf\AppData\Roaming\npm;C:\Program Files (x86)\WinRAR;C:\Program Files (x86)\Git\usr\bin\vendor_perl;C:\Program Files (x86)\Git\usr\bin\core_perl
|
||||||
|
10 verbose lifecycle NeteaseCloudMusicApi@1.2.2~test: CWD: C:\Users\ztf\Desktop\NeteaseCloudMusicApi
|
||||||
|
11 silly lifecycle NeteaseCloudMusicApi@1.2.2~test: Args: [ '/d /s /c', 'babel-node test/test.js' ]
|
||||||
|
12 silly lifecycle NeteaseCloudMusicApi@1.2.2~test: Returned: code: 1 signal: null
|
||||||
|
13 info lifecycle NeteaseCloudMusicApi@1.2.2~test: Failed to exec test script
|
||||||
|
14 verbose stack Error: NeteaseCloudMusicApi@1.2.2 test: `babel-node test/test.js`
|
||||||
|
14 verbose stack Exit status 1
|
||||||
|
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:245:16)
|
||||||
|
14 verbose stack at emitTwo (events.js:106:13)
|
||||||
|
14 verbose stack at EventEmitter.emit (events.js:191:7)
|
||||||
|
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
|
||||||
|
14 verbose stack at emitTwo (events.js:106:13)
|
||||||
|
14 verbose stack at ChildProcess.emit (events.js:191:7)
|
||||||
|
14 verbose stack at maybeClose (internal/child_process.js:852:16)
|
||||||
|
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
|
||||||
|
15 verbose pkgid NeteaseCloudMusicApi@1.2.2
|
||||||
|
16 verbose cwd C:\Users\ztf\Desktop\NeteaseCloudMusicApi
|
||||||
|
17 error Windows_NT 10.0.14376
|
||||||
|
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
|
||||||
|
19 error node v6.2.2
|
||||||
|
20 error npm v3.9.5
|
||||||
|
21 error code ELIFECYCLE
|
||||||
|
22 error NeteaseCloudMusicApi@1.2.2 test: `babel-node test/test.js`
|
||||||
|
22 error Exit status 1
|
||||||
|
23 error Failed at the NeteaseCloudMusicApi@1.2.2 test script 'babel-node test/test.js'.
|
||||||
|
23 error Make sure you have the latest version of node.js and npm installed.
|
||||||
|
23 error If you do, this is most likely a problem with the NeteaseCloudMusicApi package,
|
||||||
|
23 error not with npm itself.
|
||||||
|
23 error Tell the author that this fails on your system:
|
||||||
|
23 error babel-node test/test.js
|
||||||
|
23 error You can get information on how to open an issue for this project with:
|
||||||
|
23 error npm bugs NeteaseCloudMusicApi
|
||||||
|
23 error Or if that isn't available, you can get their info via:
|
||||||
|
23 error npm owner ls NeteaseCloudMusicApi
|
||||||
|
23 error There is likely additional logging output above.
|
||||||
|
24 verbose exit [ 1, true ]
|
||||||
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "NeteaseCloudMusicApi",
|
"name": "NeteaseCloudMusicApi",
|
||||||
"version": "1.2.1",
|
"version": "1.2.3",
|
||||||
"description": "网易云音乐nodejs版接口模块",
|
"description": "网易云音乐nodejs版接口模块",
|
||||||
"main": "build/app.js",
|
"main": "build/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "babel-node test/test.js",
|
"test": "babel-node test/test.js",
|
||||||
"build": "babel src/ -d build/"
|
"build": "babel src/ -d build/"
|
||||||
},
|
},
|
||||||
"keywords": ["NeteaseCloudMusic","网易云音乐"],
|
"keywords": ["NeteaseCloudMusic","网易云音乐","网易云"],
|
||||||
"author": "traveller",
|
"author": "traveller",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
41
src/app.js
41
src/app.js
@ -4,32 +4,30 @@ import { deepCopy } from './util'
|
|||||||
|
|
||||||
let api = {
|
let api = {
|
||||||
search: (name = null, callback = null, limit = 3, offset = 0) => {
|
search: (name = null, callback = null, limit = 3, offset = 0) => {
|
||||||
let option = deepCopy(globalOption)
|
let option = deepCopy(globalOption)
|
||||||
let url = origin + '/api/search/suggest/web'
|
let url = origin + '/api/search/suggest/web'
|
||||||
let form = {
|
let form = {
|
||||||
s: name,
|
s: name,
|
||||||
limit,
|
limit,
|
||||||
type: 1,
|
type: 1,
|
||||||
offset
|
offset
|
||||||
}
|
|
||||||
let method = 'POST'
|
|
||||||
let proxy = false
|
|
||||||
Object.assign(option, { url, form, method, proxy })
|
|
||||||
request(option, (error, response, body) => {
|
|
||||||
if (!error && response.statusCode == 200) {
|
|
||||||
let info = JSON.parse(body);
|
|
||||||
callback && callback(JSON.stringify(info, '', 2))
|
|
||||||
} else {
|
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
})
|
let method = 'POST'
|
||||||
|
Object.assign(option, { url, form, method })
|
||||||
|
request(option, (error, response, body) => {
|
||||||
|
if (!error && response.statusCode == 200) {
|
||||||
|
let info = JSON.parse(body);
|
||||||
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
|
} else {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
song: (id, callback = null) => {
|
song: (id, callback = null) => {
|
||||||
let option = deepCopy(globalOption)
|
let option = deepCopy(globalOption)
|
||||||
let url = origin + '/api/song/detail?ids=%5B' + id + '%5d'
|
let url = origin + '/api/song/detail?ids=%5B' + id + '%5d'
|
||||||
let method = 'GET'
|
let method = 'GET'
|
||||||
let proxy = false
|
Object.assign(option, { url, method })
|
||||||
Object.assign(option, { url, method, proxy })
|
|
||||||
request(option, (error, response, body) => {
|
request(option, (error, response, body) => {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
let info = JSON.parse(body);
|
let info = JSON.parse(body);
|
||||||
@ -43,8 +41,7 @@ let api = {
|
|||||||
let option = deepCopy(globalOption)
|
let option = deepCopy(globalOption)
|
||||||
let url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id
|
let url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id
|
||||||
let method = 'GET'
|
let method = 'GET'
|
||||||
let proxy = false
|
Object.assign(option, { url, method })
|
||||||
Object.assign(option, { url, method, proxy })
|
|
||||||
request(option, (error, response, body) => {
|
request(option, (error, response, body) => {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
let info = JSON.parse(body);
|
let info = JSON.parse(body);
|
||||||
|
|||||||
@ -5,7 +5,8 @@ const globalOption = {
|
|||||||
'Origin': origin,
|
'Origin': origin,
|
||||||
'Referer': origin,
|
'Referer': origin,
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
}
|
},
|
||||||
|
proxy:false
|
||||||
}
|
}
|
||||||
|
|
||||||
export { origin, globalOption }
|
export { origin, globalOption }
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
const deepCopy = (obj) => JSON.parse(JSON.stringify(obj))
|
const deepCopy = obj => JSON.parse(JSON.stringify(obj))
|
||||||
|
|
||||||
export { deepCopy }
|
export { deepCopy }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user