From c5f164a094ef582278e5d61e8f1806b2c4929a89 Mon Sep 17 00:00:00 2001 From: binaryify <821374382@qq.com> Date: Sat, 9 Jul 2016 10:55:49 +0800 Subject: [PATCH] fix error --- build/app.js | 2 +- build/component/getPlaylists.js | 32 ++++++++++++++++++++++++++++++++ package.json | 4 ++-- test/test.js | 3 ++- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 build/component/getPlaylists.js diff --git a/build/app.js b/build/app.js index cd4f66a..a8d78f7 100644 --- a/build/app.js +++ b/build/app.js @@ -26,4 +26,4 @@ var api = { getPlaylists: _getPlaylists.getPlaylists }; -exports.api = api; +exports.api = api; \ No newline at end of file diff --git a/build/component/getPlaylists.js b/build/component/getPlaylists.js new file mode 100644 index 0000000..e4c8ef5 --- /dev/null +++ b/build/component/getPlaylists.js @@ -0,0 +1,32 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getPlaylists = 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; \ No newline at end of file diff --git a/package.json b/package.json index 92a7af5..6b8d579 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "NeteaseCloudMusicApi", - "version": "1.2.8", + "version": "1.2.9", "description": "网易云音乐nodejs版接口模块", "main": "build/app.js", "scripts": { - "test": "babel-node test/test.js", + "test": "node test/test.js", "build": "babel src/ -d build/" }, "keywords": ["NeteaseCloudMusic","网易云音乐","网易云"], diff --git a/test/test.js b/test/test.js index 575a69c..2198e59 100644 --- a/test/test.js +++ b/test/test.js @@ -1,4 +1,5 @@ -import { api } from '../src/app.js' +// import { api } from '../src/app.js' +const api=require('../build/app.js').api api.search("年度之歌",data => { console.log("################Search API#################") -- GitLab