Giter VIP home page Giter VIP logo

listen1-api's Introduction

listen1-api

listen1音乐资源API库,可运行在 Nodejs 和 浏览器环境(限chrome extension 或 electron)

特性

  • 集成网易,QQ,虾米,酷狗,酷我,Bilibili平台的音乐资源API
  • 支持获取热门歌单,歌手歌单,专辑歌单
  • 支持搜索歌曲
  • 支持获取歌曲歌词信息
  • 支持获取歌曲的播放地址

编译

$ git clone [email protected]:listen1/listen1-api.git
$ cd listen1-api
$ yarn install
$ yarn build

编译后文件在dist目录下,listen1-api.jslisten1-api.min.js

安装

浏览器环境

<script src="listen1-api.min.js"></script>
<script>
  console.log(listen1Api);
</script>

Nodejs环境

const listen1Api = require('./listen1-api.min');

开始使用 (nodejs 环境)

下载压缩版本,或dist目录下的listen1-api.min.js到本地目录

const listen1Api = require('./listen1-api.min');
const platform = 'netease';
// 获取网易平台的热门歌单列表
const url = '/show_playlist?source='+platform;

listen1Api.apiGet(url).then((data) => {
  console.log(data);
});

文档

https://listen1.github.io/listen1-api

项目技术

  • 使用webpack-library-starter模板建立项目。
  • 基于Webpack 4打包。
  • ES6 语法。
  • 导出umd格式的包,支持在浏览器环境和nodejs环境运行。
  • ES6 测试基于 MochaChai
  • 使用ESLint进行语法检查。

开发使用

  1. 编译生成
  • 运行 yarn install (推荐) 或 npm install ,安装依赖包。
  • 运行 yarn buildnpm run build 来生成压缩版本的库文件。
  1. 开发者模式
  • 运行 yarn devnpm run dev 安装依赖包。生成一个非压缩版本的库文件并且在文件变化时自动重新编译。
  1. 运行测试
  • 运行 yarn testnpm run test

常用命令

  • yarn build or npm run build - 在dist目录下编译生成正式版的库文件。
  • yarn dev or npm run dev - 编译生成dev版本的库并实时更新。
  • yarn test or npm run test - 运行测试。
  • yarn test:watch or npm run test:watch - 在watch模式运行测试。

listen1-api's People

Contributors

listen1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

listen1-api's Issues

npm 编译报错

Module not found: Error: Can't resolve 'readable-stream/duplex.js' in 'E:\wamp64\www\listen1-api-master\node_modules\stream-browserify'

/search接口 部分平台歌曲获取不到

/search 接口 qq、kuwo、kugou平台的歌曲搜索不到 报以下错误:
(node:94123) UnhandledPromiseRejectionWarning: undefined
(node:94123) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Node.js 下/search接口 网易平台无响应

错误提示:(node:7904) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'songs' of undefined
at C:\Users\jinglouyan\WebstormProjects\music_server\listen1-api.min.js:8:168531
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:7904) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7904) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

直接引入编译文件,调用时报错“not a function”

在React项目中,引入
<script src="./listen1.js"></script>
调用
console.log(listen1Api); listen1Api.apiGet('/show_playlist?source=netease').then((data) => { console.log(data); });
控制台输出
{getAllProviders: ƒ, getProviderByItemId: ƒ, getProviderByName: ƒ, apiGet: ƒ, hackHeader: ƒ, …} listen1.js:8 Uncaught (in promise) TypeError: n is not a function at listen1.js:8 at new Promise (<anonymous>) at t (listen1.js:8) at Object.showPlaylist (listen1.js:8) at Object.apiGet (listen1.js:8) at Home.componentDidMount (index.js:12) at commitLifeCycles (react-dom.development.js:22101) at commitLayoutEffects (react-dom.development.js:25344) at HTMLUnknownElement.callCallback (react-dom.development.js:336) at Object.invokeGuardedCallbackDev (react-dom.development.js:385) at invokeGuardedCallback (react-dom.development.js:440) at commitRootImpl (react-dom.development.js:25082) at unstable_runWithPriority (scheduler.development.js:697) at runWithPriority$2 (react-dom.development.js:12149) at commitRoot (react-dom.development.js:24922) at finishSyncRender (react-dom.development.js:24329) at performSyncWorkOnRoot (react-dom.development.js:24307) at react-dom.development.js:12199 at unstable_runWithPriority (scheduler.development.js:697) at runWithPriority$2 (react-dom.development.js:12149) at flushSyncCallbackQueueImpl (react-dom.development.js:12194) at flushSyncCallbackQueue (react-dom.development.js:12182) at scheduleUpdateOnFiber (react-dom.development.js:23709) at Object.enqueueSetState (react-dom.development.js:13994) at DynamicComponent.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:325) at dynamic.js:91

请求get_playlist?list_id报错

const listen1Api = require('./listen1-api');
const listId = 'qqplaylist_6811314339';
const url = '/get_playlist?list_id='+listId;

console.log("开始请求了");

listen1Api.apiGet(url).then((data) => {
	console.log(data);
	// res.send(JSON.stringify(data));
});

我调用这个的时候提示

TypeError: Cannot read property 'then' of null

调用show_playlist是正常的

请问是我使用错误了么

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.