mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
'update'
This commit is contained in:
parent
07c5933e78
commit
aae785cad9
@ -35,8 +35,9 @@ api.search('年度之歌',data => {
|
|||||||
|
|
||||||
### search
|
### search
|
||||||
``` javascript
|
``` javascript
|
||||||
api.search(name:String,[callback:function,limit:Number default:3, offset:Number default:0])
|
api.search(name:String,[callback:function,onlySong:Boolean default:true,limit:Number default:3, offset:Number default:0])
|
||||||
```
|
```
|
||||||
|
说明:onlySong默认为true,如果为false,则返回一个对象,包含songs和mvs,songs和mvs均为数组
|
||||||
|
|
||||||
### lrc
|
### lrc
|
||||||
``` javascript
|
``` javascript
|
||||||
|
@ -24,6 +24,5 @@ var api = {
|
|||||||
getArtistAlbums: _getArtistAlbums.getArtistAlbums,
|
getArtistAlbums: _getArtistAlbums.getArtistAlbums,
|
||||||
getAlbums: _getAlbums.getAlbums,
|
getAlbums: _getAlbums.getAlbums,
|
||||||
getPlaylists: _getPlaylists.getPlaylists
|
getPlaylists: _getPlaylists.getPlaylists
|
||||||
|
|
||||||
};
|
};
|
||||||
exports.api = api;
|
exports.api = api;
|
@ -1,32 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.getAlbums = undefined;
|
|
||||||
|
|
||||||
var _request = require('request');
|
|
||||||
|
|
||||||
var _request2 = _interopRequireDefault(_request);
|
|
||||||
|
|
||||||
var _config = require('../config');
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
var getPlaylists = function getPlaylists(id, callback) {
|
|
||||||
var option = (0, _util.deepCopy)(_config.globalOption);
|
|
||||||
var url = _config.origin + '/api/playlist/detail?id=' + id;
|
|
||||||
var method = 'get';
|
|
||||||
Object.assign(option, { url: url, method: method });
|
|
||||||
(0, _request2.default)(option, function (err, res, body) {
|
|
||||||
if (!err && res.statusCode == 200) {
|
|
||||||
var info = JSON.parse(body);
|
|
||||||
callback && callback(JSON.stringify(info, '', 2));
|
|
||||||
} else {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
exports.getPlaylists = getPlaylists;
|
|
@ -18,8 +18,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|||||||
var search = function search() {
|
var 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 onlySong = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
|
||||||
var offset = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
|
var limit = arguments.length <= 3 || arguments[3] === undefined ? 3 : arguments[3];
|
||||||
|
var offset = arguments.length <= 4 || arguments[4] === undefined ? 0 : arguments[4];
|
||||||
|
|
||||||
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';
|
||||||
@ -34,7 +35,13 @@ var search = function search() {
|
|||||||
(0, _request2.default)(option, function (err, res, body) {
|
(0, _request2.default)(option, function (err, res, body) {
|
||||||
if (!err && res.statusCode == 200) {
|
if (!err && res.statusCode == 200) {
|
||||||
var info = JSON.parse(body);
|
var info = JSON.parse(body);
|
||||||
callback && callback(JSON.stringify(info, '', 2));
|
var data = void 0;
|
||||||
|
if (onlySong) {
|
||||||
|
data = info.result.songs;
|
||||||
|
} else {
|
||||||
|
data = { songs: info.result.songs, mvs: info.result.mvs };
|
||||||
|
}
|
||||||
|
callback && callback(JSON.stringify(data, '', 2));
|
||||||
} else {
|
} else {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "NeteaseCloudMusicApi",
|
"name": "NeteaseCloudMusicApi",
|
||||||
"version": "1.2.9",
|
"version": "1.5.0",
|
||||||
"description": "网易云音乐nodejs版接口模块",
|
"description": "网易云音乐nodejs版接口模块",
|
||||||
"main": "build/app.js",
|
"main": "build/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -12,6 +12,5 @@ let api = {
|
|||||||
getArtistAlbums: getArtistAlbums,
|
getArtistAlbums: getArtistAlbums,
|
||||||
getAlbums: getAlbums,
|
getAlbums: getAlbums,
|
||||||
getPlaylists: getPlaylists
|
getPlaylists: getPlaylists
|
||||||
|
|
||||||
}
|
}
|
||||||
export {api}
|
export {api}
|
||||||
|
@ -12,7 +12,7 @@ const getAlbums = (id, callback) => {
|
|||||||
let info = JSON.parse(body)
|
let info = JSON.parse(body)
|
||||||
callback && callback(JSON.stringify(info, '', 2))
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
} else {
|
} else {
|
||||||
console.error(err);
|
console.error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ const getArtistAlbums = (id, callback, limit = 3, offset = 0) => {
|
|||||||
let info = JSON.parse(body)
|
let info = JSON.parse(body)
|
||||||
callback && callback(JSON.stringify(info, '', 2))
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
} else {
|
} else {
|
||||||
console.error(err);
|
console.error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import { deepCopy } from '../util'
|
|||||||
const getPlaylists = (id, callback) => {
|
const getPlaylists = (id, callback) => {
|
||||||
const option = deepCopy(globalOption)
|
const option = deepCopy(globalOption)
|
||||||
const url = `${origin}/api/playlist/detail?id=${id}`
|
const url = `${origin}/api/playlist/detail?id=${id}`
|
||||||
const method = 'GET'
|
const method = 'get'
|
||||||
Object.assign(option, {url, method})
|
Object.assign(option, {url, method})
|
||||||
request(option, (err, res, body) => {
|
request(option, (err, res, body) => {
|
||||||
if(!err && res.statusCode == 200) {
|
if(!err && res.statusCode == 200) {
|
||||||
let info = JSON.parse(body)
|
let info = JSON.parse(body)
|
||||||
callback && callback(JSON.stringify(info, '', 2))
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
} else {
|
} else {
|
||||||
console.error(err);
|
console.error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import request from 'request'
|
|||||||
import { origin, globalOption } from '../config'
|
import { origin, globalOption } from '../config'
|
||||||
import { deepCopy } from '../util'
|
import { deepCopy } from '../util'
|
||||||
|
|
||||||
const search = (name = null, callback = null, limit = 3, offset = 0) => {
|
const search = (name = null, callback = null,onlySong=true, limit = 3, offset = 0) => {
|
||||||
const option = deepCopy(globalOption)
|
const option = deepCopy(globalOption)
|
||||||
const url = `${origin}/api/search/suggest/web`
|
const url = `${origin}/api/search/suggest/web`
|
||||||
const form = {
|
const form = {
|
||||||
@ -15,8 +15,14 @@ const search = (name = null, callback = null, limit = 3, offset = 0) => {
|
|||||||
Object.assign(option, { url, form, method })
|
Object.assign(option, { url, form, method })
|
||||||
request(option, (err, res, body) => {
|
request(option, (err, res, body) => {
|
||||||
if (!err && res.statusCode == 200) {
|
if (!err && res.statusCode == 200) {
|
||||||
let info = JSON.parse(body);
|
let info = JSON.parse(body)
|
||||||
callback && callback(JSON.stringify(info, '', 2))
|
let data
|
||||||
|
if(onlySong){
|
||||||
|
data=info.result.songs
|
||||||
|
}else{
|
||||||
|
data={songs:info.result.songs,mvs:info.result.mvs}
|
||||||
|
}
|
||||||
|
callback&&callback(JSON.stringify(data,'',2))
|
||||||
} else {
|
} else {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// import { api } from '../src/app.js'
|
// import { api } from '../src/app.js'
|
||||||
const api=require('../build/app.js').api
|
const {api}=require('../build/app.js')
|
||||||
|
|
||||||
api.search("年度之歌",data => {
|
api.search("年度之歌",data => {
|
||||||
console.log("################Search API#################")
|
console.log("################Search API#################")
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user