diff --git a/.gitignore b/.gitignore index 5f6a916..6b608ed 100644 --- a/.gitignore +++ b/.gitignore @@ -28,5 +28,4 @@ pnpm-debug.log* #Electron-builder output /dist_electron -NeteaseCloudMusicApi-master NeteaseCloudMusicApi-master.zip diff --git a/.npmrc b/.npmrc index ed2598e..c154130 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,4 @@ # 如果发现 npm / yarn 安装太慢,可以解除注释 -# registry=https://registry.npm.taobao.org/ -# ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron \ No newline at end of file +registry=https://registry.npm.taobao.org/ +ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron +phantomjs_cdnurl=https://npm.taobao.org/dist/phantomjs \ No newline at end of file diff --git a/napi/.editorconfig b/napi/.editorconfig new file mode 100644 index 0000000..6c725ce --- /dev/null +++ b/napi/.editorconfig @@ -0,0 +1,34 @@ + +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{js,py}] +charset = utf-8 + +# 4 space indentation +[*.py] +indent_style = space +indent_size = 4 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +# Indentation override for all JS under lib directory +[*.{js,ts}] +indent_style = space +indent_size = 2 + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/napi/.eslintrc.js b/napi/.eslintrc.js new file mode 100644 index 0000000..e4b2246 --- /dev/null +++ b/napi/.eslintrc.js @@ -0,0 +1,49 @@ +module.exports = { + root: true, + parserOptions: { + parser: 'babel-eslint', + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['html'], + extends: ['plugin:prettier/recommended'], + env: { + browser: true, + node: true, + }, + + rules: { + indent: ['error', 2, { SwitchCase: 1 }], + 'space-infix-ops': ['error', { int32Hint: false }], + 'key-spacing': [ + 2, + { + beforeColon: false, + afterColon: true, + }, + ], + 'no-octal': 2, + 'no-redeclare': 2, + 'comma-spacing': 2, + 'no-new-object': 2, + 'arrow-spacing': 2, + quotes: [ + 2, + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true, + }, + ], + }, + overrides: [ + { + files: ['**/*.ts'], + parser: '@typescript-eslint/parser', + extends: [ + 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin + 'prettier/@typescript-eslint', + ], + }, + ], +}; diff --git a/napi/.gitignore b/napi/.gitignore new file mode 100644 index 0000000..f284b53 --- /dev/null +++ b/napi/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +node_modules +*.log +.idea +.vscode \ No newline at end of file diff --git a/napi/.npmignore b/napi/.npmignore new file mode 100644 index 0000000..3f24434 --- /dev/null +++ b/napi/.npmignore @@ -0,0 +1,3 @@ +static +docs +node_modules \ No newline at end of file diff --git a/napi/.prettierrc b/napi/.prettierrc new file mode 100644 index 0000000..aea847c --- /dev/null +++ b/napi/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": true, + "trailingComma": "all", + "singleQuote": true +} diff --git a/napi/README.MD b/napi/README.MD new file mode 100644 index 0000000..679cf3e --- /dev/null +++ b/napi/README.MD @@ -0,0 +1,312 @@ +# 网易云音乐 API + +网易云音乐 Node.js API service + +
+ +## 灵感来自 + +[disoul/electron-cloud-music](https://github.com/disoul/electron-cloud-music) + +[darknessomi/musicbox](https://github.com/darknessomi/musicbox) + +[sqaiyan/netmusic-node](https://github.com/sqaiyan/netmusic-node) + + +## 环境要求 + +需要 NodeJS 8.12+ 环境 + +## 安装 + +```shell + +$ git clone git@github.com:Binaryify/NeteaseCloudMusicApi.git + +$ npm install +``` + +或者 +```shell +$ git clone https://github.com/Binaryify/NeteaseCloudMusicApi.git + +$ npm install +``` + +## 运行 + +```shell +$ node app.js +``` + +服务器启动默认端口为 3000,若不想使用 3000 端口,可使用以下命令: Mac/Linux + +```shell +$ PORT=4000 node app.js +``` + +windows 下使用 git-bash 或者 cmder 等终端执行以下命令: + +```shell +$ set PORT=4000 && node app.js +``` + +## 可以在Node.js调用 +v3.31.0后支持Node.js调用,导入的方法为`module`内的文件名,返回内容包含`status`和`body`,`status`为状态码,`body`为请求返回内容,参考`module_example` 文件夹下的 `test.js` +```js +const { login_cellphone, user_cloud } = require('NeteaseCloudMusicApi') +async function main() { + try { + const result = await login_cellphone({ + phone: '手机号', + password: '密码' + }) + console.log(result) + const result2 = await user_cloud({ + cookie: result.body.cookie // 凭证 + }) + console.log(result2.body) + + } catch (error) { + console.log(error) + } +} +main() +``` + +## 支持 TypeScript +```ts +// test.ts +import { banner } from 'NeteaseCloudMusicApi' +banner({ type:0 }).then(res=>{ + console.log(res) +}) +``` + + +## 使用文档 + +[文档地址](https://binaryify.github.io/NeteaseCloudMusicApi) + +[文档地址2](https://neteasecloudmusicapi.vercel.app) + +![文档](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/docs.png) + + +## 功能特性 +1. 登录 +2. 刷新登录 +3. 发送验证码 +4. 校验验证码 +5. 注册(修改密码) +6. 获取用户信息 , 歌单,收藏,mv, dj 数量 +7. 获取用户歌单 +8. 获取用户电台 +9. 获取用户关注列表 +10. 获取用户粉丝列表 +11. 获取用户动态 +12. 获取用户播放记录 +13. 获取精品歌单 +14. 获取歌单详情 +15. 搜索 +16. 搜索建议 +17. 获取歌词 +18. 歌曲评论 +19. 收藏单曲到歌单 +20. 专辑评论 +21. 歌单评论 +22. mv 评论 +23. 电台节目评论 +24. banner +25. 获取歌曲详情 +26. 获取专辑内容 +27. 获取歌手单曲 +28. 获取歌手 mv +29. 获取歌手专辑 +30. 获取歌手描述 +31. 获取相似歌手 +32. 获取相似歌单 +33. 相似 mv +34. 获取相似音乐 +35. 获取最近 5 个听了这首歌的用户 +36. 获取每日推荐歌单 +37. 获取每日推荐歌曲 +38. 私人 FM +39. 签到 +40. 喜欢音乐 +41. 垃圾桶 +42. 歌单 ( 网友精选碟 ) +43. 新碟上架 +44. 热门歌手 +45. 最新 mv +46. 推荐 mv +47. 推荐歌单 +48. 推荐新音乐 +49. 推荐电台 +50. 推荐节目 +51. 独家放送 +52. mv 排行 +53. 获取 mv 数据 +54. 播放 mv/视频 +55. 排行榜 +56. 歌手榜 +57. 云盘 +58. 电台 - 推荐 +59. 电台 - 分类 +60. 电台 - 分类推荐 +61. 电台 - 订阅 +62. 电台 - 详情 +63. 电台 - 节目 +64. 给评论点赞 +65. 获取动态 +66. 热搜列表(简略) +67. 发送私信 +68. 发送私信歌单 +69. 新建歌单 +70. 收藏/取消收藏歌单 +71. 歌单分类 +72. 收藏的歌手列表 +73. 订阅的电台列表 +74. 相关歌单推荐 +75. 付费精选接口 +76. 音乐是否可用检查接口 +77. 登录状态 +78. 获取视频播放地址 +79. 发送/删除评论 +80. 热门评论 +81. 视频评论 +82. 退出登录 +83. 所有榜单 +84. 所有榜单内容摘要 +85. 收藏视频 +86. 收藏 MV +87. 视频详情 +88. 相关视频 +89. 关注用户 +90. 新歌速递 +91. 喜欢音乐列表(无序) +92. 收藏的 MV 列表 +93. 获取最新专辑 +94. 听歌打卡 +95. 获取视频标签/分类下的视频 +96. 已收藏专辑列表 +97. 获取动态评论 +98. 歌单收藏者列表 +99. 云盘歌曲删除 +100. 热门话题 +101. 电台 - 推荐类型 +102. 电台 - 非热门类型 +103. 电台 - 今日优选 +104. 心动模式/智能播放 +105. 转发动态 +106. 删除动态 +107. 分享歌曲、歌单、mv、电台、电台节目到动态 +108. 通知-私信 +109. 通知-评论 +110. 通知-@我 +111. 通知-通知 +112. 设置 +113. 云盘数据详情 +114. 私信内容 +115. 我的数字专辑 +116. batch批量请求接口 +117. 获取视频标签列表 +118. 全部mv +119. 网易出品mv +120. 收藏/取消收藏专辑 +121. 专辑动态信息 +122. 热搜列表(详细) +123. 更换绑定手机 +124. 检测手机号码是否已注册 +125. 初始化昵称 +126. 更新歌单描述 +127. 更新歌单名 +128. 更新歌单标签 +129. 默认搜索关键词 +130. 删除歌单 +131. 电台banner +132. 用户电台 +133. 热门电台 +134. 电台 - 节目详情 +135. 电台 - 节目榜 +136. 电台 - 新晋电台榜/热门电台榜 +137. 类别热门电台 +138. 云村热评 +139. 电台24小时节目榜 +140. 电台24小时主播榜 +141. 电台最热主播榜 +142. 电台主播新人榜 +143. 电台付费精品榜 +144. 歌手热门50首歌曲 +145. 购买数字专辑 +146. 获取 mv 点赞转发评论数数据 +147. 获取视频点赞转发评论数数据 +148. 调整歌单顺序 +149. 调整歌曲顺序 +150. 独家放送列表 +151. 获取推荐视频 +152. 获取视频分类列表 +153. 获取全部视频列表接口 +154. 获取历史日推可用日期列表 +155. 获取历史日推详细数据 +156. 国家编码列表 +157. 首页-发现 +158. 首页-发现-圆形图标入口列表 +159. 数字专辑-全部新碟 +160. 数字专辑-热门新碟 +161. 数字专辑&数字单曲-榜单 +162. 数字专辑-语种风格馆 +163. 数字专辑详情 +164. 更新头像 +165. 歌单封面上传 +166. 楼层评论 +167. 歌手全部歌曲 +168. 精品歌单标签列表 +169. 用户等级信息 +170. 电台个性推荐 +171. 用户绑定信息 +172. 用户绑定手机 +173. 新版评论 +174. 点赞过的视频 +175. 收藏视频到视频歌单 +176. 删除视频歌单里的视频 +177. 最近播放的视频 +178. 音乐日历 +179. 电台订阅者列表 +180. 云贝签到信息 +181. 云贝签到 +182. 云贝所有任务 +183. 云贝todo任务 +184. 云贝今日签到信息 +185. 云贝完成任务 +186. 云贝收入 +187. 云贝支出 +188. 云贝账户信息 +189. 账号信息 + +## 更新日志 + +[changelog](https://github.com/Binaryify/NeteaseCloudMusicApi/blob/master/CHANGELOG.MD) + +## 单元测试 + +```shell +$ npm test +``` + +![单元测试](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/screenshot1.png) +![单元测试](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/screenshot2.png) + +## 贡献者 +![](https://opencollective.com/NeteaseCloudMusicApi/contributors.svg?width=890) + + +## License + +[The MIT License (MIT)](https://github.com/Binaryify/NeteaseCloudMusicApi/blob/master/LICENSE) diff --git a/napi/app.js b/napi/app.js new file mode 100644 index 0000000..b1f3294 --- /dev/null +++ b/napi/app.js @@ -0,0 +1,117 @@ +const fs = require('fs'); +const path = require('path'); +const express = require('express'); +const bodyParser = require('body-parser'); +const request = require('./util/request'); +const packageJSON = require('./package.json'); +const exec = require('child_process').exec; +const cache = require('./util/apicache').middleware; +const { cookieToJson } = require('./util/index'); +const fileUpload = require('express-fileupload'); +// version check +exec('npm info NeteaseCloudMusicApi version', (err, stdout, stderr) => { + if (!err) { + let version = stdout.trim(); + if (packageJSON.version < version) { + console.log( + `最新版本: ${version}, 当前版本: ${packageJSON.version}, 请及时更新`, + ); + } + } +}); + +const app = express(); + +// CORS & Preflight request +app.use((req, res, next) => { + if (req.path !== '/' && !req.path.includes('.')) { + res.set({ + 'Access-Control-Allow-Credentials': true, + 'Access-Control-Allow-Origin': req.headers.origin || '*', + 'Access-Control-Allow-Headers': 'X-Requested-With,Content-Type', + 'Access-Control-Allow-Methods': 'PUT,POST,GET,DELETE,OPTIONS', + 'Content-Type': 'application/json; charset=utf-8', + }); + } + req.method === 'OPTIONS' ? res.status(204).end() : next(); +}); + +// cookie parser +app.use((req, res, next) => { + req.cookies = {}; + (req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => { + let crack = pair.indexOf('='); + if (crack < 1 || crack == pair.length - 1) return; + req.cookies[ + decodeURIComponent(pair.slice(0, crack)).trim() + ] = decodeURIComponent(pair.slice(crack + 1)).trim(); + }); + next(); +}); + +// body parser +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: false })); + +app.use(fileUpload()); + +// static +app.use(express.static(path.join(__dirname, 'public'))); + +// cache +app.use(cache('2 minutes', (req, res) => res.statusCode === 200)); +// router +const special = { + 'daily_signin.js': '/daily_signin', + 'fm_trash.js': '/fm_trash', + 'personal_fm.js': '/personal_fm', +}; + +fs.readdirSync(path.join(__dirname, 'module')) + .reverse() + .forEach((file) => { + if (!file.endsWith('.js')) return; + let route = + file in special + ? special[file] + : '/' + file.replace(/\.js$/i, '').replace(/_/g, '/'); + let question = require(path.join(__dirname, 'module', file)); + + app.use(route, (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + + question(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }); + }); + +const port = process.env.PORT || 3000; +const host = process.env.HOST || ''; + +app.server = app.listen(port, host, () => { + console.log(`server running @ http://${host ? host : 'localhost'}:${port}`); +}); + +module.exports = app; diff --git a/napi/buildScript.js b/napi/buildScript.js new file mode 100644 index 0000000..e557384 --- /dev/null +++ b/napi/buildScript.js @@ -0,0 +1,60 @@ +const fs = require('fs'); +const path = require('path'); +const express = require('express'); +const request = require('./util/request'); +const strip = require('strip-comments'); +var router = express.Router(); +const special = { + 'daily_signin.js': '/daily_signin', + 'fm_trash.js': '/fm_trash', + 'personal_fm.js': '/personal_fm', +}; + +const app = express(); +const temp = {}; + +fs.readdirSync(path.join(__dirname, 'module')) + .reverse() + .forEach((file) => { + if (!file.endsWith('.js')) return; + let route = + file in special + ? special[file] + : '/' + file.replace(/\.js$/i, '').replace(/_/g, '/'); + let question = require(path.join(__dirname, 'module', file)); + // console.log(question.toString()) + const func = `(req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const ${file.replace(/\.js$/i, '')} = ${strip(question.toString())}; + ${file.replace(/\.js$/i, '')}(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + }`; + temp[route] = func; + }); + +fs.writeFileSync( + path.resolve(__dirname, './test_result.json'), + JSON.stringify(temp), +); diff --git a/napi/interface.d.ts b/napi/interface.d.ts new file mode 100644 index 0000000..548768d --- /dev/null +++ b/napi/interface.d.ts @@ -0,0 +1,1311 @@ +export interface RequestBaseConfig { + cookie?: string; + realIP?: string; // IPv4/IPv6 filled in X-Real-IP + proxy?: string; // HTTP proxy +} + +export interface MultiPageConfig { + limit?: string | number; + offset?: string | number; +} + +export interface ImageUploadConfig { + imgFile: { + name: string; + data: string | Buffer; + }; + imgSize?: number; + imgX?: number; + imgY?: number; +} + +export interface APIBaseResponse { + code: number; + cookie: string; + [index: string]: unknown; +} + +export interface Response { + status: number; // The Http Response Code + body: APIBaseResponse; // API Response body + cookie: string[]; +} + +export const enum SubAction { + sub = 1, + unsub = 0, +} + +export function activate_init_profile( + params: { nickname: string } & RequestBaseConfig, +): Promise请在控制台看结果
+ + + + + diff --git a/napi/renovate.json b/napi/renovate.json new file mode 100644 index 0000000..4f39080 --- /dev/null +++ b/napi/renovate.json @@ -0,0 +1,3 @@ +{ + "extends": ["config:base"] +} diff --git a/napi/routes.js b/napi/routes.js new file mode 100644 index 0000000..ede337b --- /dev/null +++ b/napi/routes.js @@ -0,0 +1,8810 @@ +const { cookieToJson } = require('./util/index'); +const request = require('./util/request'); +module.exports = { + '/yunbei/today': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_today = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/point/today/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_today(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/tasks/todo': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_tasks_todo = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/usertool/task/todo/query`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_tasks_todo(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/tasks': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_tasks = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/usertool/task/list/all`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_tasks(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/task/finish': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_task_finish = (query, request) => { + const data = { + userTaskId: query.userTaskId, + depositCode: query.depositCode || '0', + }; + return request( + 'POST', + `https://music.163.com/api/usertool/task/point/receive`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_task_finish(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/sign': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_sign = (query, request) => { + const data = { type: '0' }; + return request( + 'POST', + `https://music.163.com/api/point/dailyTask`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_sign(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/receipt': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_receipt = (query, request) => { + const data = { limit: query.limit || 10, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/store/api/point/receipt`, + data, + { + crypto: 'api', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_receipt(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/info': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_info = (query, request) => { + const data = {}; + return request('POST', `https://music.163.com/api/v1/user/info`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + yunbei_info(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei/expense': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei_expense = (query, request) => { + const data = { limit: query.limit || 10, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/store/api/point/expense`, + data, + { + crypto: 'api', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei_expense(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/yunbei': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const yunbei = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/point/signed/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + yunbei(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/weblog': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const weblog = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/feedback/weblog`, + query.data || {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + weblog(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/url': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_url = (query, request) => { + const data = { + ids: '["' + query.id + '"]', + resolution: query.res || 1080, + }; + return request( + 'POST', + `https://music.163.com/weapi/cloudvideo/playurl`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_url(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/timeline/recommend': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_timeline_recommend = (query, request) => { + const data = { + offset: query.offset || 0, + filterLives: '[]', + withProgramInfo: 'true', + needUrl: '1', + resolution: '480', + }; + return request( + 'POST', + `https://music.163.com/api/videotimeline/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_timeline_recommend(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/timeline/all': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_timeline_all = (query, request) => { + const data = { + groupId: 0, + offset: query.offset || 0, + need_preview_url: 'true', + total: true, + }; + return request( + 'POST', + `https://music.163.com/api/videotimeline/otherclient/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_timeline_all(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/sub': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_sub = (query, request) => { + query.t = query.t == 1 ? 'sub' : 'unsub'; + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/cloudvideo/video/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_sub(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/group/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_group_list = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/cloudvideo/group/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_group_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/group': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_group = (query, request) => { + const data = { + groupId: query.id, + offset: query.offset || 0, + need_preview_url: 'true', + total: true, + }; + return request( + 'POST', + `https://music.163.com/api/videotimeline/videogroup/otherclient/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_group(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/detail/info': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_detail_info = (query, request) => { + const data = { threadid: `R_VI_62_${query.vid}`, composeliked: true }; + return request( + 'POST', + `https://music.163.com/api/comment/commentthread/info`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_detail_info(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_detail = (query, request) => { + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/cloudvideo/v1/video/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/video/category/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const video_category_list = (query, request) => { + const data = { + offset: query.offset || 0, + total: 'true', + limit: query.limit || 99, + }; + return request( + 'POST', + `https://music.163.com/api/cloudvideo/category/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + video_category_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_update = (query, request) => { + const data = { + avatarImgId: '0', + birthday: query.birthday, + city: query.city, + gender: query.gender, + nickname: query.nickname, + province: query.province, + signature: query.signature, + }; + return request( + 'POST', + `https://music.163.com/weapi/user/profile/update`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/subcount': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_subcount = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/subcount`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_subcount(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/replacephone': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_replacephone = (query, request) => { + const data = { + phone: query.phone, + captcha: query.captcha, + oldcaptcha: query.oldcaptcha, + countrycode: query.countrycode || '86', + }; + return request( + 'POST', + `https://music.163.com/api/user/replaceCellphone`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_replacephone(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/record': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_record = (query, request) => { + const data = { uid: query.uid, type: query.type || 0 }; + return request( + 'POST', + `https://music.163.com/weapi/v1/play/record`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_record(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/playlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_playlist = (query, request) => { + const data = { + uid: query.uid, + limit: query.limit || 30, + offset: query.offset || 0, + includeVideo: true, + }; + return request('POST', `https://music.163.com/api/user/playlist`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + user_playlist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/level': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_level = (query, request) => { + const data = {}; + return request('POST', `https://music.163.com/weapi/user/level`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + user_level(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/follows': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_follows = (query, request) => { + const data = { + offset: query.offset || 0, + limit: query.limit || 30, + order: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/user/getfollows/${query.uid}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_follows(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/followeds': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_followeds = (query, request) => { + const data = { + userId: query.uid, + time: query.lasttime || -1, + limit: query.limit || 30, + }; + return request( + 'POST', + `https://music.163.com/eapi/user/getfolloweds/${query.uid}`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/user/getfolloweds', + realIP: query.realIP, + }, + ); + }; + user_followeds(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/event': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_event = (query, request) => { + const data = { + getcounts: true, + time: query.lasttime || -1, + limit: query.limit || 30, + total: false, + }; + return request( + 'POST', + `https://music.163.com/weapi/event/get/${query.uid}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_event(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/dj': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_dj = (query, request) => { + const data = { limit: query.limit || 30, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/weapi/dj/program/${query.uid}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_dj(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_detail = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/v1/user/detail/${query.uid}`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/cloud/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_cloud_detail = (query, request) => { + const id = query.id.replace(/\s/g, '').split(','); + const data = { songIds: id }; + return request( + 'POST', + `https://music.163.com/weapi/v1/cloud/get/byids`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_cloud_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/cloud/del': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_cloud_del = (query, request) => { + const data = { songIds: [query.id] }; + return request('POST', `https://music.163.com/weapi/cloud/del`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + user_cloud_del(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/cloud': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_cloud = (query, request) => { + const data = { limit: query.limit || 30, offset: query.offset || 0 }; + return request('POST', `https://music.163.com/weapi/v1/cloud/get`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + user_cloud(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/binding': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_binding = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/v1/user/bindings/${query.uid}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_binding(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/audio': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_audio = (query, request) => { + const data = { userId: query.uid }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/get/byuser`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_audio(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/user/account': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const user_account = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/nuser/account/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + user_account(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/toplist/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const toplist_detail = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/toplist/detail`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + toplist_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/toplist/artist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const toplist_artist = (query, request) => { + const data = { + type: query.type || 1, + limit: 100, + offset: 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/toplist/artist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + toplist_artist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/toplist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const toplist = (query, request) => { + return request( + 'POST', + `https://music.163.com/api/toplist`, + {}, + { + crypto: 'linuxapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + toplist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/song': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_song = (query, request) => { + const data = { areaId: query.type || 0, total: true }; + return request( + 'POST', + `https://music.163.com/weapi/v1/discovery/new/songs`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + top_song(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/playlist/highquality': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_playlist_highquality = (query, request) => { + const data = { + cat: query.cat || '全部', + limit: query.limit || 50, + lasttime: query.before || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/api/playlist/highquality/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + top_playlist_highquality(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/playlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_playlist = (query, request) => { + const data = { + cat: query.cat || '全部', + order: query.order || 'hot', + limit: query.limit || 50, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/playlist/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + top_playlist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/mv': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_mv = (query, request) => { + const data = { + area: query.area || '', + limit: query.limit || 30, + offset: query.offset || 0, + total: true, + }; + return request('POST', `https://music.163.com/weapi/mv/toplist`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + top_mv(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_list = (query, request) => { + query.cookie.os = 'pc'; + if (query.idx) { + return Promise.resolve({ + status: 500, + body: { code: 500, msg: '不支持此方式调用,只支持id调用' }, + }); + } + const data = { id: query.id, n: '500', s: '0' }; + return request( + 'POST', + `https://interface3.music.163.com/api/playlist/v4/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + top_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/artists': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_artists = (query, request) => { + const data = { + limit: query.limit || 50, + offset: query.offset || 0, + total: true, + }; + return request('POST', `https://music.163.com/weapi/artist/top`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + top_artists(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/top/album': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const top_album = (query, request) => { + const date = new Date(); + const data = { + area: query.area || 'ALL', + limit: query.limit || 50, + offset: query.offset || 0, + type: query.type || 'new', + year: query.year || date.getFullYear(), + month: query.month || date.getMonth() + 1, + total: false, + rcmd: true, + }; + return request( + 'POST', + `https://music.163.com/api/discovery/new/albums/area`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + top_album(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/song/url': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const song_url = (query, request) => { + if (!('MUSIC_U' in query.cookie)) + query.cookie._ntes_nuid = crypto.randomBytes(16).toString('hex'); + query.cookie.os = 'pc'; + const data = { + ids: '[' + query.id + ']', + br: parseInt(query.br || 999000), + }; + return request( + 'POST', + `https://interface3.music.163.com/eapi/song/enhance/player/url`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + url: '/api/song/enhance/player/url', + }, + ); + }; + song_url(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/song/order/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const song_order_update = (query, request) => { + const data = { pid: query.pid, trackIds: query.ids, op: 'update' }; + return request( + 'POST', + `http://interface.music.163.com/api/playlist/manipulate/tracks`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/playlist/desc/update', + realIP: query.realIP, + }, + ); + }; + song_order_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/song/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const song_detail = (query, request) => { + query.ids = query.ids.split(/\s*,\s*/); + const data = { + c: '[' + query.ids.map((id) => '{"id":' + id + '}').join(',') + ']', + ids: '[' + query.ids.join(',') + ']', + }; + return request( + 'POST', + `https://music.163.com/weapi/v3/song/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + song_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/simi/user': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const simi_user = (query, request) => { + const data = { + songid: query.id, + limit: query.limit || 50, + offset: query.offset || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/discovery/simiUser`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + simi_user(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/simi/song': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const simi_song = (query, request) => { + const data = { + songid: query.id, + limit: query.limit || 50, + offset: query.offset || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/discovery/simiSong`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + simi_song(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/simi/playlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const simi_playlist = (query, request) => { + const data = { + songid: query.id, + limit: query.limit || 50, + offset: query.offset || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/discovery/simiPlaylist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + simi_playlist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/simi/mv': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const simi_mv = (query, request) => { + const data = { mvid: query.mvid }; + return request( + 'POST', + `https://music.163.com/weapi/discovery/simiMV`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + simi_mv(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/simi/artist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const simi_artist = (query, request) => { + const data = { artistid: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/discovery/simiArtist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + simi_artist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/share/resource': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const share_resource = (query, request) => { + const data = { + type: query.type || 'song', + msg: query.msg || '', + id: query.id || '', + }; + return request( + 'POST', + `https://music.163.com/weapi/share/friends/resource`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + share_resource(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/setting': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const setting = (query, request) => { + const data = {}; + return request('POST', `https://music.163.com/api/user/setting`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + setting(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/send/text': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const send_text = (query, request) => { + query.cookie.os = 'pc'; + const data = { + type: 'text', + msg: query.msg, + userIds: '[' + query.user_ids + ']', + }; + return request( + 'POST', + `https://music.163.com/weapi/msg/private/send`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + send_text(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/send/playlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const send_playlist = (query, request) => { + query.cookie.os = 'pc'; + const data = { + id: query.playlist, + type: 'playlist', + msg: query.msg, + userIds: '[' + query.user_ids + ']', + }; + return request( + 'POST', + `https://music.163.com/weapi/msg/private/send`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + send_playlist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/search/suggest': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const search_suggest = (query, request) => { + const data = { s: query.keywords || '' }; + let type = query.type == 'mobile' ? 'keyword' : 'web'; + return request( + 'POST', + `https://music.163.com/weapi/search/suggest/` + type, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + search_suggest(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/search/multimatch': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const search_multimatch = (query, request) => { + const data = { type: query.type || 1, s: query.keywords || '' }; + return request( + 'POST', + `https://music.163.com/weapi/search/suggest/multimatch`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + search_multimatch(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/search/hot/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const search_hot_detail = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/weapi/hotsearchlist/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + search_hot_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/search/hot': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const search_hot = (query, request) => { + const data = { type: 1111 }; + return request('POST', `https://music.163.com/weapi/search/hot`, data, { + crypto: 'weapi', + ua: 'mobile', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + search_hot(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/search/default': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const search_default = (query, request) => { + return request( + 'POST', + `https://interface3.music.163.com/eapi/search/defaultkeyword/get`, + {}, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/search/defaultkeyword/get', + realIP: query.realIP, + }, + ); + }; + search_default(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/search': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const search = (query, request) => { + const data = { + s: query.keywords, + type: query.type || 1, + limit: query.limit || 30, + offset: query.offset || 0, + }; + return request('POST', `https://music.163.com/weapi/search/get`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + search(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/scrobble': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const scrobble = (query, request) => { + const data = { + logs: JSON.stringify([ + { + action: 'play', + json: { + download: 0, + end: 'playend', + id: query.id, + sourceId: query.sourceid, + time: query.time, + type: 'song', + wifi: 0, + }, + }, + ]), + }; + return request( + 'POST', + `https://music.163.com/weapi/feedback/weblog`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + scrobble(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/resource/like': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const resource_like = (query, request) => { + query.cookie.os = 'pc'; + query.t = query.t == 1 ? 'like' : 'unlike'; + query.type = { 1: 'R_MV_5_', 4: 'A_DJ_1_', 5: 'R_VI_62_', 6: 'A_EV_2_' }[ + query.type + ]; + const data = { threadId: query.type + query.id }; + if (query.type === 'A_EV_2_') { + data.threadId = query.threadId; + } + return request( + 'POST', + `https://music.163.com/weapi/resource/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + resource_like(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/related/allvideo': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const related_allvideo = (query, request) => { + const data = { id: query.id, type: /^\\d+$/.test(query.id) ? 0 : 1 }; + return request( + 'POST', + `https://music.163.com/weapi/cloudvideo/v1/allvideo/rcmd`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + related_allvideo(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/register/cellphone': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const register_cellphone = (query, request) => { + query.cookie.os = 'pc'; + const data = { + captcha: query.captcha, + phone: query.phone, + password: crypto.createHash('md5').update(query.password).digest('hex'), + nickname: query.nickname, + }; + return request( + 'POST', + `https://music.163.com/api/register/cellphone`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + register_cellphone(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/recommend/songs': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const recommend_songs = (query, request) => { + query.cookie.os = 'ios'; + const data = {}; + return request( + 'POST', + `https://music.163.com/api/v3/discovery/recommend/songs`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + recommend_songs(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/recommend/resource': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const recommend_resource = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/v1/discovery/recommend/resource`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + recommend_resource(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/rebind': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const rebind = (query, request) => { + const data = { + captcha: query.captcha, + phone: query.phone, + oldcaptcha: query.oldcaptcha, + ctcode: query.ctcode || '86', + }; + return request( + 'POST', + `https://music.163.com/api/user/replaceCellphone`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + rebind(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/program/recommend': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const program_recommend = (query, request) => { + const data = { + cateId: query.type, + limit: query.limit || 10, + offset: query.offset || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/program/recommend/v1`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + program_recommend(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playmode/intelligence/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playmode_intelligence_list = (query, request) => { + const data = { + songId: query.id, + type: 'fromPlayOne', + playlistId: query.pid, + startMusicId: query.sid || query.id, + count: query.count || 1, + }; + return request( + 'POST', + `https://music.163.com/weapi/playmode/intelligence/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playmode_intelligence_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/video/recent': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_video_recent = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/playlist/video/recent`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_video_recent(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_update = (query, request) => { + query.cookie.os = 'pc'; + query.desc = query.desc || ''; + query.tags = query.tags || ''; + const data = { + '/api/playlist/desc/update': `{\"id\":${query.id},\"desc\":\"${query.desc}\"}`, + '/api/playlist/tags/update': `{\"id\":${query.id},\"tags\":\"${query.tags}\"}`, + '/api/playlist/update/name': `{\"id\":${query.id},\"name\":\"${query.name}\"}`, + }; + return request('POST', `https://music.163.com/weapi/batch`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + playlist_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/tracks': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_tracks = async (query, request) => { + query.cookie.os = 'pc'; + const tracks = query.tracks.split(','); + const data = { + op: query.op, + pid: query.pid, + trackIds: JSON.stringify(tracks), + imme: 'true', + }; + try { + const res = await request( + 'POST', + `https://music.163.com/api/playlist/manipulate/tracks`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + return { status: 200, body: { ...res } }; + } catch (error) { + if (error.body.code === 512) { + return request( + 'POST', + `https://music.163.com/api/playlist/manipulate/tracks`, + { + op: query.op, + pid: query.pid, + trackIds: JSON.stringify([...tracks, ...tracks]), + imme: 'true', + }, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + } + } + }; + playlist_tracks(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/track/delete': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_track_delete = async (query, request) => { + query.cookie.os = 'pc'; + query.ids = query.ids || ''; + const data = { + id: query.id, + tracks: JSON.stringify( + query.ids.split(',').map((item) => { + return { type: 3, id: item }; + }), + ), + }; + return request( + 'POST', + `https://music.163.com/api/playlist/track/delete`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_track_delete(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/track/add': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_track_add = async (query, request) => { + query.cookie.os = 'pc'; + query.ids = query.ids || ''; + const data = { + id: query.pid, + tracks: JSON.stringify( + query.ids.split(',').map((item) => { + return { type: 3, id: item }; + }), + ), + }; + console.log(data); + return request( + 'POST', + `https://music.163.com/api/playlist/track/add`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_track_add(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/tags/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_tags_update = (query, request) => { + const data = { id: query.id, tags: query.tags }; + return request( + 'POST', + `https://interface3.music.163.com/eapi/playlist/tags/update`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/playlist/tags/update', + realIP: query.realIP, + }, + ); + }; + playlist_tags_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/subscribers': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_subscribers = (query, request) => { + const data = { + id: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/playlist/subscribers`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_subscribers(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/subscribe': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_subscribe = (query, request) => { + query.t = query.t == 1 ? 'subscribe' : 'unsubscribe'; + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/playlist/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_subscribe(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/order/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_order_update = (query, request) => { + query.cookie.os = 'pc'; + const data = { ids: query.ids }; + return request( + 'POST', + `https://music.163.com/api/playlist/order/update`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_order_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/name/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_name_update = (query, request) => { + const data = { id: query.id, name: query.name }; + return request( + 'POST', + `https://interface3.music.163.com/eapi/playlist/update/name`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/playlist/update/name', + realIP: query.realIP, + }, + ); + }; + playlist_name_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/mylike': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_mylike = (query, request) => { + const data = { time: query.time || '-1', limit: query.limit || '12' }; + return request( + 'POST', + `https://music.163.com/api/mlog/playlist/mylike/bytime/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_mylike(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/hot': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_hot = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/playlist/hottags`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_hot(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/highquality/tags': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_highquality_tags = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/playlist/highquality/tags`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_highquality_tags(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_detail = (query, request) => { + const data = { id: query.id, n: 100000, s: query.s || 8 }; + return request( + 'POST', + `https://music.163.com/api/v6/playlist/detail`, + data, + { + crypto: 'linuxapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/desc/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_desc_update = (query, request) => { + const data = { id: query.id, desc: query.desc }; + return request( + 'POST', + `https://interface3.music.163.com/eapi/playlist/desc/update`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/playlist/desc/update', + realIP: query.realIP, + }, + ); + }; + playlist_desc_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/delete': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_delete = (query, request) => { + query.cookie.os = 'pc'; + const data = { ids: '[' + query.id + ']' }; + return request( + 'POST', + `https://music.163.com/weapi/playlist/remove`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_delete(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/create': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_create = (query, request) => { + query.cookie.os = 'pc'; + const data = { + name: query.name, + privacy: query.privacy, + type: query.type || 'NORMAL', + }; + return request( + 'POST', + `https://music.163.com/api/playlist/create`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_create(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/cover/update': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_cover_update = async (query, request) => { + const uploadInfo = await uploadPlugin(query, request); + const res = await request( + 'POST', + `https://music.163.com/weapi/playlist/cover/update`, + { id: query.id, coverImgId: uploadInfo.imgId }, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + return { + status: 200, + body: { code: 200, data: { ...uploadInfo, ...res.body } }, + }; + }; + playlist_cover_update(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/playlist/catlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const playlist_catlist = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/playlist/catalogue`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + playlist_catlist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personalized/privatecontent/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personalized_privatecontent_list = (query, request) => { + const data = { + offset: query.offset || 0, + total: 'true', + limit: query.limit || 60, + }; + return request( + 'POST', + `https://music.163.com/api/v2/privatecontent/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personalized_privatecontent_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personalized/privatecontent': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personalized_privatecontent = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/personalized/privatecontent`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personalized_privatecontent(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personalized/newsong': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personalized_newsong = (query, request) => { + const data = { + type: 'recommend', + limit: query.limit || 10, + areaId: query.areaId || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/personalized/newsong`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personalized_newsong(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personalized/mv': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personalized_mv = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/personalized/mv`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personalized_mv(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personalized/djprogram': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personalized_djprogram = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/personalized/djprogram`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personalized_djprogram(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personalized': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personalized = (query, request) => { + const data = { limit: query.limit || 30, total: true, n: 1000 }; + return request( + 'POST', + `https://music.163.com/weapi/personalized/playlist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personalized(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/personal_fm': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const personal_fm = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/v1/radio/get`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + personal_fm(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/url': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_url = (query, request) => { + const data = { id: query.id, r: query.r || 1080 }; + return request( + 'POST', + `https://music.163.com/weapi/song/enhance/play/mv/url`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_url(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/sublist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_sublist = (query, request) => { + const data = { + limit: query.limit || 25, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/cloudvideo/allvideo/sublist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_sublist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/sub': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_sub = (query, request) => { + query.t = query.t == 1 ? 'sub' : 'unsub'; + const data = { mvId: query.mvid, mvIds: '["' + query.mvid + '"]' }; + return request( + 'POST', + `https://music.163.com/weapi/mv/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_sub(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/first': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_first = (query, request) => { + const data = { + area: query.area || '', + limit: query.limit || 30, + total: true, + }; + return request( + 'POST', + `https://interface.music.163.com/weapi/mv/first`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_first(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/exclusive/rcmd': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_exclusive_rcmd = (query, request) => { + const data = { offset: query.offset || 0, limit: query.limit || 30 }; + return request( + 'POST', + `https://interface.music.163.com/api/mv/exclusive/rcmd`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_exclusive_rcmd(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/detail/info': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_detail_info = (query, request) => { + const data = { threadid: `R_MV_5_${query.mvid}`, composeliked: true }; + return request( + 'POST', + `https://music.163.com/api/comment/commentthread/info`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_detail_info(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_detail = (query, request) => { + const data = { id: query.mvid }; + return request('POST', `https://music.163.com/api/v1/mv/detail`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + mv_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/mv/all': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const mv_all = (query, request) => { + const data = { + tags: JSON.stringify({ + 地区: query.area || '全部', + 类型: query.type || '全部', + 排序: query.order || '上升最快', + }), + offset: query.offset || 0, + total: 'true', + limit: query.limit || 30, + }; + return request( + 'POST', + `https://interface.music.163.com/api/mv/all`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + mv_all(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/msg/private/history': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const msg_private_history = (query, request) => { + const data = { + userId: query.uid, + limit: query.limit || 30, + time: query.before || 0, + total: 'true', + }; + return request( + 'POST', + `https://music.163.com/api/msg/private/history`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + msg_private_history(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/msg/private': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const msg_private = (query, request) => { + const data = { + offset: query.offset || 0, + limit: query.limit || 30, + total: 'true', + }; + return request( + 'POST', + `https://music.163.com/api/msg/private/users`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + msg_private(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/msg/notices': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const msg_notices = (query, request) => { + const data = { limit: query.limit || 30, time: query.lasttime || -1 }; + return request('POST', `https://music.163.com/api/msg/notices`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + msg_notices(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/msg/forwards': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const msg_forwards = (query, request) => { + const data = { + offset: query.offset || 0, + limit: query.limit || 30, + total: 'true', + }; + return request('POST', `https://music.163.com/api/forwards/get`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + msg_forwards(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/msg/comments': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const msg_comments = (query, request) => { + const data = { + beforeTime: query.before || '-1', + limit: query.limit || 30, + total: 'true', + uid: query.uid, + }; + return request( + 'POST', + `https://music.163.com/api/v1/user/comments/${query.uid}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + msg_comments(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/lyric': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const lyric = (query, request) => { + query.cookie.os = 'pc'; + const data = { id: query.id, lv: -1, kv: -1, tv: -1 }; + return request('POST', `https://music.163.com/api/song/lyric`, data, { + crypto: 'linuxapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + lyric(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/logout': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const logout = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/logout`, + {}, + { + crypto: 'weapi', + ua: 'pc', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + logout(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/login/status': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const login_status = (query, request) => { + return request( + 'GET', + `https://music.163.com`, + {}, + { cookie: query.cookie, proxy: query.proxy, realIP: query.realIP }, + ).then((response) => { + try { + let profile = eval( + `(${/GUser\\s*=\\s*([^;]+);/.exec(response.body)[1]})`, + ); + let bindings = eval( + `(${/GBinds\\s*=\\s*([^;]+);/.exec(response.body)[1]})`, + ); + response.body = { code: 200, profile: profile, bindings: bindings }; + return response; + } catch (err) { + response.status = 301; + response.body = { code: 301 }; + return Promise.reject(response); + } + }); + }; + login_status(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/login/refresh': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const login_refresh = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/login/token/refresh`, + {}, + { + crypto: 'weapi', + ua: 'pc', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + login_refresh(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/login/cellphone': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const login_cellphone = async (query, request) => { + query.cookie.os = 'pc'; + const data = { + phone: query.phone, + countrycode: query.countrycode || '86', + password: + query.md5_password || + crypto.createHash('md5').update(query.password).digest('hex'), + rememberLogin: 'true', + }; + let result = await request( + 'POST', + `https://music.163.com/weapi/login/cellphone`, + data, + { + crypto: 'weapi', + ua: 'pc', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + if (result.body.code === 200) { + result = { + status: 200, + body: { ...result.body, cookie: result.cookie.join(';') }, + cookie: result.cookie, + }; + } + return result; + }; + login_cellphone(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/login': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const login = async (query, request) => { + query.cookie.os = 'pc'; + const data = { + username: query.email, + password: + query.md5_password || + crypto.createHash('md5').update(query.password).digest('hex'), + rememberLogin: 'true', + }; + let result = await request( + 'POST', + `https://music.163.com/weapi/login`, + data, + { + crypto: 'weapi', + ua: 'pc', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + if (result.body.code === 502) { + return { + status: 200, + body: { msg: '账号或密码错误', code: 502, message: '账号或密码错误' }, + }; + } + if (result.body.code === 200) { + result = { + status: 200, + body: { ...result.body, cookie: result.cookie.join(';') }, + cookie: result.cookie, + }; + } + return result; + }; + login(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/likelist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const likelist = (query, request) => { + const data = { uid: query.uid }; + return request( + 'POST', + `https://music.163.com/weapi/song/like/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + likelist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/like': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const like = (query, request) => { + query.like = query.like == 'false' ? false : true; + const data = { trackId: query.id, like: query.like }; + return request( + 'POST', + `https://music.163.com/weapi/radio/like?alg=${ + query.alg || 'itembased' + }&trackId=${query.id}&time=${query.time || 25}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + like(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/hot/topic': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const hot_topic = (query, request) => { + const data = { limit: query.limit || 20, offset: query.offset || 0 }; + return request('POST', `https://music.163.com/weapi/act/hot`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + hot_topic(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/homepage/dragon/ball': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const homepage_dragon_ball = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/eapi/homepage/dragon/ball/static`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/homepage/dragon/ball/static', + realIP: query.realIP, + }, + ); + }; + homepage_dragon_ball(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/homepage/block/page': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const homepage_block_page = (query, request) => { + const data = { refresh: query.refresh || true }; + return request( + 'POST', + `https://music.163.com/api/homepage/block/page`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + homepage_block_page(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/history/recommend/songs/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const history_recommend_songs_detail = (query, request) => { + query.cookie.os = 'ios'; + const data = { date: query.date || '' }; + return request( + 'POST', + `https://music.163.com/api/discovery/recommend/songs/history/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + history_recommend_songs_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/history/recommend/songs': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const history_recommend_songs = (query, request) => { + query.cookie.os = 'ios'; + const data = {}; + return request( + 'POST', + `https://music.163.com/api/discovery/recommend/songs/history/recent`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + history_recommend_songs(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/follow': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const follow = (query, request) => { + query.cookie.os = 'pc'; + query.t = query.t == 1 ? 'follow' : 'delfollow'; + return request( + 'POST', + `https://music.163.com/weapi/user/${query.t}/${query.id}`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + follow(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/fm_trash': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const fm_trash = (query, request) => { + const data = { songId: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/radio/trash/add?alg=RT&songId=${ + query.id + }&time=${query.time || 25}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + fm_trash(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/event/forward': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const event_forward = (query, request) => { + query.cookie.os = 'pc'; + const data = { + forwards: query.forwards, + id: query.evId, + eventUserId: query.uid, + }; + return request( + 'POST', + `https://music.163.com/weapi/event/forward`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + event_forward(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/event/del': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const event_del = (query, request) => { + const data = { id: query.evId }; + return request('POST', `https://music.163.com/eapi/event/delete`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + event_del(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/event': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const event = (query, request) => { + const data = { + pagesize: query.pagesize || 20, + lasttime: query.lasttime || -1, + }; + return request('POST', `https://music.163.com/weapi/v1/event/get`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + event(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/toplist/popular': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_toplist_popular = (query, request) => { + const data = { limit: query.limit || 100 }; + return request( + 'POST', + `https://music.163.com/api/dj/toplist/popular`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_toplist_popular(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/toplist/pay': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_toplist_pay = (query, request) => { + const data = { limit: query.limit || 100 }; + return request( + 'POST', + `https://music.163.com/api/djradio/toplist/pay`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_toplist_pay(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/toplist/newcomer': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_toplist_newcomer = (query, request) => { + const data = { limit: query.limit || 100, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/api/dj/toplist/newcomer`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_toplist_newcomer(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/toplist/hours': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_toplist_hours = (query, request) => { + const data = { limit: query.limit || 100 }; + return request( + 'POST', + `https://music.163.com/api/dj/toplist/hours`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_toplist_hours(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/toplist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_toplist = (query, request) => { + const data = { + limit: query.limit || 100, + offset: query.offset || 0, + type: typeMap[query.type || 'new'] || '0', + }; + return request( + 'POST', + `https://music.163.com/api/djradio/toplist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_toplist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/today/perfered': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_today_perfered = (query, request) => { + const data = { page: query.page || 0 }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/home/today/perfered`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_today_perfered(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/subscriber': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_subscriber = (query, request) => { + const data = { + time: query.time || '-1', + id: query.id, + limit: query.limit || '20', + total: 'true', + }; + return request( + 'POST', + `https://music.163.com/api/djradio/subscriber`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_subscriber(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/sublist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_sublist = (query, request) => { + const data = { + limit: query.limit || 30, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/get/subed`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_sublist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/sub': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_sub = (query, request) => { + query.t = query.t == 1 ? 'sub' : 'unsub'; + const data = { id: query.rid }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_sub(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/recommend/type': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_recommend_type = (query, request) => { + const data = { cateId: query.type }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/recommend`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_recommend_type(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/recommend': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_recommend = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/djradio/recommend/v1`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_recommend(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/radio/hot': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_radio_hot = (query, request) => { + const data = { + cateId: query.cateId, + limit: query.limit || 30, + offset: query.offset || 0, + }; + return request('POST', `https://music.163.com/api/djradio/hot`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + dj_radio_hot(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/program/toplist/hours': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_program_toplist_hours = (query, request) => { + const data = { limit: query.limit || 100 }; + return request( + 'POST', + `https://music.163.com/api/djprogram/toplist/hours`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_program_toplist_hours(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/program/toplist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_program_toplist = (query, request) => { + const data = { limit: query.limit || 100, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/api/program/toplist/v1`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_program_toplist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/program/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_program_detail = (query, request) => { + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/api/dj/program/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_program_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/program': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_program = (query, request) => { + const data = { + radioId: query.rid, + limit: query.limit || 30, + offset: query.offset || 0, + asc: toBoolean(query.asc), + }; + return request( + 'POST', + `https://music.163.com/weapi/dj/program/byradio`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_program(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/personalize/recommend': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_personalize_recommend = (query, request) => { + return request( + 'POST', + `https://music.163.com/api/djradio/personalize/rcmd`, + { limit: query.limit || 6 }, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_personalize_recommend(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/paygift': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_paygift = (query, request) => { + const data = { limit: query.limit || 30, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/home/paygift/list?_nmclfl=1`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_paygift(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/hot': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_hot = (query, request) => { + const data = { limit: query.limit || 30, offset: query.offset || 0 }; + return request( + 'POST', + `https://music.163.com/weapi/djradio/hot/v1`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_hot(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_detail = (query, request) => { + const data = { id: query.rid }; + return request('POST', `https://music.163.com/api/djradio/v2/get`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + dj_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/catelist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_catelist = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/djradio/category/get`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_catelist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/category/recommend': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_category_recommend = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/djradio/home/category/recommend`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_category_recommend(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/category/excludehot': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_category_excludehot = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/djradio/category/excludehot`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_category_excludehot(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/dj/banner': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const dj_banner = (query, request) => { + const data = {}; + query.cookie.os = 'pc'; + return request( + 'POST', + `https://music.163.com/weapi/djradio/banner/get`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + dj_banner(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/digitalAlbum/purchased': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const digitalAlbum_purchased = (query, request) => { + const data = { + limit: query.limit || 30, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/api/digitalAlbum/purchased`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + digitalAlbum_purchased(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/digitalAlbum/ordering': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const digitalAlbum_ordering = (query, request) => { + const data = { + business: 'Album', + paymentMethod: query.payment, + digitalResources: JSON.stringify([ + { business: 'Album', resourceID: query.id, quantity: query.quantity }, + ]), + from: 'web', + }; + return request( + 'POST', + `https://music.163.com/api/ordering/web/digital`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + digitalAlbum_ordering(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/daily_signin': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const daily_signin = (query, request) => { + const data = { type: query.type || 0 }; + return request( + 'POST', + `https://music.163.com/weapi/point/dailyTask`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + daily_signin(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/countries/code/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const countries_code_list = (query, request) => { + const data = {}; + return request( + 'POST', + `https://interface3.music.163.com/eapi/lbs/countries/v1`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/lbs/countries/v1', + realIP: query.realIP, + }, + ); + }; + countries_code_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/video': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_video = (query, request) => { + query.cookie.os = 'pc'; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/comments/R_VI_62_${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_video(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/playlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_playlist = (query, request) => { + query.cookie.os = 'pc'; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/comments/A_PL_0_${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_playlist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/new': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_new = (query, request) => { + query.cookie.os = 'pc'; + query.type = { + 0: 'R_SO_4_', + 1: 'R_MV_5_', + 2: 'A_PL_0_', + 3: 'R_AL_3_', + 4: 'A_DJ_1_', + 5: 'R_VI_62_', + 6: 'A_EV_2_', + }[query.type]; + const threadId = query.type + query.id; + const pageSize = query.pageSize || 20; + const pageNo = query.pageNo || 1; + const data = { + threadId: threadId, + pageNo, + showInner: query.showInner || true, + pageSize, + cursor: + +query.sortType === 3 ? query.cursor || '0' : (pageNo - 1) * pageSize, + sortType: query.sortType || 1, + }; + return request( + 'POST', + `https://music.163.com/api/v2/resource/comments`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + url: '/api/v2/resource/comments', + }, + ); + }; + comment_new(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/mv': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_mv = (query, request) => { + query.cookie.os = 'pc'; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/comments/R_MV_5_${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_mv(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/music': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_music = (query, request) => { + query.cookie.os = 'pc'; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/api/v1/resource/comments/R_SO_4_${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_music(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/like': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_like = (query, request) => { + query.cookie.os = 'pc'; + query.t = query.t == 1 ? 'like' : 'unlike'; + query.type = { + 0: 'R_SO_4_', + 1: 'R_MV_5_', + 2: 'A_PL_0_', + 3: 'R_AL_3_', + 4: 'A_DJ_1_', + 5: 'R_VI_62_', + 6: 'A_EV_2_', + }[query.type]; + const data = { threadId: query.type + query.id, commentId: query.cid }; + if (query.type == 'A_EV_2_') { + data.threadId = query.threadId; + } + return request( + 'POST', + `https://music.163.com/weapi/v1/comment/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_like(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/hotwall/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_hotwall_list = (query, request) => { + const data = {}; + return request( + 'POST', + `https://music.163.com/api/comment/hotwall/list/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_hotwall_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/hot': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_hot = (query, request) => { + query.cookie.os = 'pc'; + query.type = { + 0: 'R_SO_4_', + 1: 'R_MV_5_', + 2: 'A_PL_0_', + 3: 'R_AL_3_', + 4: 'A_DJ_1_', + 5: 'R_VI_62_', + }[query.type]; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/hotcomments/${query.type}${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_hot(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/floor': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_floor = (query, request) => { + query.type = { + 0: 'R_SO_4_', + 1: 'R_MV_5_', + 2: 'A_PL_0_', + 3: 'R_AL_3_', + 4: 'A_DJ_1_', + 5: 'R_VI_62_', + }[query.type]; + const data = { + parentCommentId: query.parentCommentId, + threadId: query.type + query.id, + time: query.time || -1, + limit: query.limit || 20, + }; + return request( + 'POST', + `https://music.163.com/api/resource/comment/floor/get`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_floor(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/event': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_event = (query, request) => { + const data = { + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/comments/${query.threadId}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_event(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/dj': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_dj = (query, request) => { + query.cookie.os = 'pc'; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/comments/A_DJ_1_${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_dj(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment/album': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment_album = (query, request) => { + query.cookie.os = 'pc'; + const data = { + rid: query.id, + limit: query.limit || 20, + offset: query.offset || 0, + beforeTime: query.before || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/v1/resource/comments/R_AL_3_${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment_album(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/comment': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const comment = (query, request) => { + query.cookie.os = 'pc'; + query.t = { 1: 'add', 0: 'delete', 2: 'reply' }[query.t]; + query.type = { + 0: 'R_SO_4_', + 1: 'R_MV_5_', + 2: 'A_PL_0_', + 3: 'R_AL_3_', + 4: 'A_DJ_1_', + 5: 'R_VI_62_', + 6: 'A_EV_2_', + }[query.type]; + const data = { threadId: query.type + query.id }; + if (query.type == 'A_EV_2_') { + data.threadId = query.threadId; + } + if (query.t == 'add') data.content = query.content; + else if (query.t == 'delete') data.commentId = query.commentId; + else if (query.t == 'reply') { + data.commentId = query.commentId; + data.content = query.content; + } + return request( + 'POST', + `https://music.163.com/weapi/resource/comments/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + comment(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/cloudsearch': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const cloudsearch = (query, request) => { + const data = { + s: query.keywords, + type: query.type || 1, + limit: query.limit || 30, + offset: query.offset || 0, + }; + return request( + 'POST', + `https://music.163.com/weapi/cloudsearch/get/web`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + cloudsearch(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/check/music': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const check_music = (query, request) => { + const data = { + ids: '[' + parseInt(query.id) + ']', + br: parseInt(query.br || 999000), + }; + return request( + 'POST', + `https://music.163.com/weapi/song/enhance/player/url`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ).then((response) => { + let playable = false; + if (response.body.code == 200) { + if (response.body.data[0].code == 200) { + playable = true; + } + } + if (playable) { + response.body = { success: true, message: 'ok' }; + return response; + } else { + response.status = 404; + response.body = { success: false, message: '亲爱的,暂无版权' }; + return Promise.reject(response); + } + }); + }; + check_music(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/cellphone/existence/check': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const cellphone_existence_check = (query, request) => { + const data = { cellphone: query.phone, countrycode: query.countrycode }; + return request( + 'POST', + `https://music.163.com/eapi/cellphone/existence/check`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + url: '/api/cellphone/existence/check', + realIP: query.realIP, + }, + ); + }; + cellphone_existence_check(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/captcha/verify': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const captcha_verify = (query, request) => { + const data = { + ctcode: query.ctcode || '86', + cellphone: query.phone, + captcha: query.captcha, + }; + return request( + 'POST', + `https://music.163.com/weapi/sms/captcha/verify`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + captcha_verify(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/captcha/sent': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const captcha_sent = (query, request) => { + const data = { ctcode: query.ctcode || '86', cellphone: query.phone }; + return request( + 'POST', + `https://music.163.com/weapi/sms/captcha/sent`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + captcha_sent(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/calendar': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const calendar = (query, request) => { + const data = { + startTime: query.startTime || Date.now(), + endTime: query.endTime || Date.now(), + }; + return request( + 'POST', + `https://music.163.com/api/mcalendar/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + calendar(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/banner': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const banner = (query, request) => { + const type = + { 0: 'pc', 1: 'android', 2: 'iphone', 3: 'ipad' }[query.type || 0] || + 'pc'; + return request( + 'POST', + `https://music.163.com/api/v2/banner/get`, + { clientType: type }, + { crypto: 'linuxapi', proxy: query.proxy, realIP: query.realIP }, + ); + }; + banner(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/avatar/upload': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const avatar_upload = async (query, request) => { + const uploadInfo = await uploadPlugin(query, request); + const res = await request( + 'POST', + `https://music.163.com/weapi/user/avatar/upload/v1`, + { imgid: uploadInfo.imgId }, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + return { + status: 200, + body: { code: 200, data: { ...uploadInfo, ...res.body } }, + }; + }; + avatar_upload(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/audio/match': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const audio_match = (query, request) => { + query.cookie.os = 'pc'; + const data = { + algorithmCode: 'shazam_v2', + times: 1, + sessionId: 'C999431ACDC84EDBB984763654E6F8D7', + duration: 3.3066249999999995, + from: 'recognize-song', + rawdata: realData, + }; + return request( + 'POST', + `https://music.163.com/api/music/audio/match`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + audio_match(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artists': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artists = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/v1/artist/${query.id}`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artists(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/top/song': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_top_song = (query, request) => { + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/api/artist/top/song`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artist_top_song(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/sublist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_sublist = (query, request) => { + const data = { + limit: query.limit || 25, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/artist/sublist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artist_sublist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/sub': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_sub = (query, request) => { + query.t = query.t == 1 ? 'sub' : 'unsub'; + const data = { artistId: query.id, artistIds: '[' + query.id + ']' }; + return request( + 'POST', + `https://music.163.com/weapi/artist/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artist_sub(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/songs': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_songs = (query, request) => { + query.cookie.os = 'pc'; + const data = { + id: query.id, + private_cloud: 'true', + work_type: 1, + order: query.order || 'hot', + offset: query.offset || 0, + limit: query.limit || 100, + }; + return request( + 'POST', + `https://music.163.com/api/v1/artist/songs`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artist_songs(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/mv': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_mv = (query, request) => { + const data = { + artistId: query.id, + limit: query.limit, + offset: query.offset, + total: true, + }; + return request('POST', `https://music.163.com/weapi/artist/mvs`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + artist_mv(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_list = (query, request) => { + const data = { + initial: isNaN(query.initial) + ? (query.initial || '').toUpperCase().charCodeAt() || undefined + : query.initial, + offset: query.offset || 0, + limit: query.limit || 30, + total: true, + type: query.type || '1', + area: query.area, + }; + return request('POST', `https://music.163.com/api/v1/artist/list`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + artist_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/desc': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_desc = (query, request) => { + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/artist/introduction`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artist_desc(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/artist/album': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const artist_album = (query, request) => { + const data = { + limit: query.limit || 30, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/artist/albums/${query.id}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + artist_album(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/sublist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_sublist = (query, request) => { + const data = { + limit: query.limit || 25, + offset: query.offset || 0, + total: true, + }; + return request( + 'POST', + `https://music.163.com/weapi/album/sublist`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_sublist(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/sub': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_sub = (query, request) => { + query.t = query.t == 1 ? 'sub' : 'unsub'; + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/api/album/${query.t}`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_sub(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/songsaleboard': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_songsaleboard = (query, request) => { + let data = { albumType: query.albumType || 0 }; + const type = query.type || 'daily'; + if (type === 'year') { + data = { ...data, year: query.year }; + } + return request( + 'POST', + `https://music.163.com/api/feealbum/songsaleboard/${type}/type`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_songsaleboard(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/newest': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_newest = (query, request) => { + return request( + 'POST', + `https://music.163.com/api/discovery/newAlbum`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_newest(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/new': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_new = (query, request) => { + const data = { + limit: query.limit || 30, + offset: query.offset || 0, + total: true, + area: query.area || 'ALL', + }; + return request('POST', `https://music.163.com/weapi/album/new`, data, { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }); + }; + album_new(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/list/style': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_list_style = (query, request) => { + const data = { + limit: query.limit || 10, + offset: query.offset || 0, + total: true, + area: query.area || 'Z_H', + }; + return request( + 'POST', + `https://music.163.com/weapi/vipmall/appalbum/album/style`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_list_style(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/list': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_list = (query, request) => { + const data = { + limit: query.limit || 30, + offset: query.offset || 0, + total: true, + area: query.area || 'ALL', + type: query.type, + }; + return request( + 'POST', + `https://music.163.com/weapi/vipmall/albumproduct/list`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_list(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/detail/dynamic': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_detail_dynamic = (query, request) => { + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/api/album/detail/dynamic`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_detail_dynamic(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album/detail': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album_detail = (query, request) => { + const data = { id: query.id }; + return request( + 'POST', + `https://music.163.com/weapi/vipmall/albumproduct/detail`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album_detail(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/album': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const album = (query, request) => { + return request( + 'POST', + `https://music.163.com/weapi/v1/album/${query.id}`, + {}, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ); + }; + album(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/activate/init/profile': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const activate_init_profile = (query, request) => { + const data = { nickname: query.nickname }; + return request( + 'POST', + `https://music.163.com/eapi/activate/initProfile`, + data, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + url: '/api/activate/initProfile', + }, + ); + }; + activate_init_profile(query, request) + .then((answer) => { + console.log('[OK]', decodeURIComponent(req.originalUrl)); + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }) + .catch((answer) => { + console.log('[ERR]', decodeURIComponent(req.originalUrl), { + status: answer.status, + body: answer.body, + }); + if (answer.body.code == '301') answer.body.msg = '需要登录'; + res.append('Set-Cookie', answer.cookie); + res.status(answer.status).send(answer.body); + }); + }, + '/related/playlist': (req, res) => { + if (typeof req.query.cookie === 'string') { + req.query.cookie = cookieToJson(req.query.cookie); + } + let query = Object.assign( + {}, + { cookie: req.cookies }, + req.query, + req.body, + req.files, + ); + const related_playlist = (query, request) => { + return request( + 'GET', + `https://music.163.com/playlist?id=${query.id}`, + {}, + { + ua: 'pc', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ).then((response) => { + try { + const pattern = /
+ * app.get('/api/cache/performance', (req, res) => {
+ * res.json(apicache.getPerformance())
+ * })
+ *
+ */
+ this.getPerformance = function () {
+ return performanceArray.map(function (p) {
+ return p.report();
+ });
+ };
+
+ this.getIndex = function (group) {
+ if (group) {
+ return index.groups[group];
+ } else {
+ return index;
+ }
+ };
+
+ this.middleware = function cache(
+ strDuration,
+ middlewareToggle,
+ localOptions,
+ ) {
+ var duration = instance.getDuration(strDuration);
+ var opt = {};
+
+ middlewareOptions.push({
+ options: opt,
+ });
+
+ var options = function (localOptions) {
+ if (localOptions) {
+ middlewareOptions.find(function (middleware) {
+ return middleware.options === opt;
+ }).localOptions = localOptions;
+ }
+
+ syncOptions();
+
+ return opt;
+ };
+
+ options(localOptions);
+
+ /**
+ * A Function for non tracking performance
+ */
+ function NOOPCachePerformance() {
+ this.report = this.hit = this.miss = function () {}; // noop;
+ }
+
+ /**
+ * A function for tracking and reporting hit rate. These statistics are returned by the getPerformance() call above.
+ */
+ function CachePerformance() {
+ /**
+ * Tracks the hit rate for the last 100 requests.
+ * If there have been fewer than 100 requests, the hit rate just considers the requests that have happened.
+ */
+ this.hitsLast100 = new Uint8Array(100 / 4); // each hit is 2 bits
+
+ /**
+ * Tracks the hit rate for the last 1000 requests.
+ * If there have been fewer than 1000 requests, the hit rate just considers the requests that have happened.
+ */
+ this.hitsLast1000 = new Uint8Array(1000 / 4); // each hit is 2 bits
+
+ /**
+ * Tracks the hit rate for the last 10000 requests.
+ * If there have been fewer than 10000 requests, the hit rate just considers the requests that have happened.
+ */
+ this.hitsLast10000 = new Uint8Array(10000 / 4); // each hit is 2 bits
+
+ /**
+ * Tracks the hit rate for the last 100000 requests.
+ * If there have been fewer than 100000 requests, the hit rate just considers the requests that have happened.
+ */
+ this.hitsLast100000 = new Uint8Array(100000 / 4); // each hit is 2 bits
+
+ /**
+ * The number of calls that have passed through the middleware since the server started.
+ */
+ this.callCount = 0;
+
+ /**
+ * The total number of hits since the server started
+ */
+ this.hitCount = 0;
+
+ /**
+ * The key from the last cache hit. This is useful in identifying which route these statistics apply to.
+ */
+ this.lastCacheHit = null;
+
+ /**
+ * The key from the last cache miss. This is useful in identifying which route these statistics apply to.
+ */
+ this.lastCacheMiss = null;
+
+ /**
+ * Return performance statistics
+ */
+ this.report = function () {
+ return {
+ lastCacheHit: this.lastCacheHit,
+ lastCacheMiss: this.lastCacheMiss,
+ callCount: this.callCount,
+ hitCount: this.hitCount,
+ missCount: this.callCount - this.hitCount,
+ hitRate: this.callCount == 0 ? null : this.hitCount / this.callCount,
+ hitRateLast100: this.hitRate(this.hitsLast100),
+ hitRateLast1000: this.hitRate(this.hitsLast1000),
+ hitRateLast10000: this.hitRate(this.hitsLast10000),
+ hitRateLast100000: this.hitRate(this.hitsLast100000),
+ };
+ };
+
+ /**
+ * Computes a cache hit rate from an array of hits and misses.
+ * @param {Uint8Array} array An array representing hits and misses.
+ * @returns a number between 0 and 1, or null if the array has no hits or misses
+ */
+ this.hitRate = function (array) {
+ var hits = 0;
+ var misses = 0;
+ for (var i = 0; i < array.length; i++) {
+ var n8 = array[i];
+ for (j = 0; j < 4; j++) {
+ switch (n8 & 3) {
+ case 1:
+ hits++;
+ break;
+ case 2:
+ misses++;
+ break;
+ }
+ n8 >>= 2;
+ }
+ }
+ var total = hits + misses;
+ if (total == 0) return null;
+ return hits / total;
+ };
+
+ /**
+ * Record a hit or miss in the given array. It will be recorded at a position determined
+ * by the current value of the callCount variable.
+ * @param {Uint8Array} array An array representing hits and misses.
+ * @param {boolean} hit true for a hit, false for a miss
+ * Each element in the array is 8 bits, and encodes 4 hit/miss records.
+ * Each hit or miss is encoded as to bits as follows:
+ * 00 means no hit or miss has been recorded in these bits
+ * 01 encodes a hit
+ * 10 encodes a miss
+ */
+ this.recordHitInArray = function (array, hit) {
+ var arrayIndex = ~~(this.callCount / 4) % array.length;
+ var bitOffset = (this.callCount % 4) * 2; // 2 bits per record, 4 records per uint8 array element
+ var clearMask = ~(3 << bitOffset);
+ var record = (hit ? 1 : 2) << bitOffset;
+ array[arrayIndex] = (array[arrayIndex] & clearMask) | record;
+ };
+
+ /**
+ * Records the hit or miss in the tracking arrays and increments the call count.
+ * @param {boolean} hit true records a hit, false records a miss
+ */
+ this.recordHit = function (hit) {
+ this.recordHitInArray(this.hitsLast100, hit);
+ this.recordHitInArray(this.hitsLast1000, hit);
+ this.recordHitInArray(this.hitsLast10000, hit);
+ this.recordHitInArray(this.hitsLast100000, hit);
+ if (hit) this.hitCount++;
+ this.callCount++;
+ };
+
+ /**
+ * Records a hit event, setting lastCacheMiss to the given key
+ * @param {string} key The key that had the cache hit
+ */
+ this.hit = function (key) {
+ this.recordHit(true);
+ this.lastCacheHit = key;
+ };
+
+ /**
+ * Records a miss event, setting lastCacheMiss to the given key
+ * @param {string} key The key that had the cache miss
+ */
+ this.miss = function (key) {
+ this.recordHit(false);
+ this.lastCacheMiss = key;
+ };
+ }
+
+ var perf = globalOptions.trackPerformance
+ ? new CachePerformance()
+ : new NOOPCachePerformance();
+
+ performanceArray.push(perf);
+
+ var cache = function (req, res, next) {
+ function bypass() {
+ debug('bypass detected, skipping cache.');
+ return next();
+ }
+
+ // initial bypass chances
+ if (!opt.enabled) return bypass();
+ if (
+ req.headers['x-apicache-bypass'] ||
+ req.headers['x-apicache-force-fetch']
+ )
+ return bypass();
+
+ // REMOVED IN 0.11.1 TO CORRECT MIDDLEWARE TOGGLE EXECUTE ORDER
+ // if (typeof middlewareToggle === 'function') {
+ // if (!middlewareToggle(req, res)) return bypass()
+ // } else if (middlewareToggle !== undefined && !middlewareToggle) {
+ // return bypass()
+ // }
+
+ // embed timer
+ req.apicacheTimer = new Date();
+
+ // In Express 4.x the url is ambigious based on where a router is mounted. originalUrl will give the full Url
+ var key = req.originalUrl || req.url;
+
+ // Remove querystring from key if jsonp option is enabled
+ if (opt.jsonp) {
+ key = url.parse(key).pathname;
+ }
+
+ // add appendKey (either custom function or response path)
+ if (typeof opt.appendKey === 'function') {
+ key += '$$appendKey=' + opt.appendKey(req, res);
+ } else if (opt.appendKey.length > 0) {
+ var appendKey = req;
+
+ for (var i = 0; i < opt.appendKey.length; i++) {
+ appendKey = appendKey[opt.appendKey[i]];
+ }
+ key += '$$appendKey=' + appendKey;
+ }
+
+ // attempt cache hit
+ var redis = opt.redisClient;
+ var cached = !redis ? memCache.getValue(key) : null;
+
+ // send if cache hit from memory-cache
+ if (cached) {
+ var elapsed = new Date() - req.apicacheTimer;
+ debug(
+ 'sending cached (memory-cache) version of',
+ key,
+ logDuration(elapsed),
+ );
+
+ perf.hit(key);
+ return sendCachedResponse(
+ req,
+ res,
+ cached,
+ middlewareToggle,
+ next,
+ duration,
+ );
+ }
+
+ // send if cache hit from redis
+ if (redis && redis.connected) {
+ try {
+ redis.hgetall(key, function (err, obj) {
+ if (!err && obj && obj.response) {
+ var elapsed = new Date() - req.apicacheTimer;
+ debug(
+ 'sending cached (redis) version of',
+ key,
+ logDuration(elapsed),
+ );
+
+ perf.hit(key);
+ return sendCachedResponse(
+ req,
+ res,
+ JSON.parse(obj.response),
+ middlewareToggle,
+ next,
+ duration,
+ );
+ } else {
+ perf.miss(key);
+ return makeResponseCacheable(
+ req,
+ res,
+ next,
+ key,
+ duration,
+ strDuration,
+ middlewareToggle,
+ );
+ }
+ });
+ } catch (err) {
+ // bypass redis on error
+ perf.miss(key);
+ return makeResponseCacheable(
+ req,
+ res,
+ next,
+ key,
+ duration,
+ strDuration,
+ middlewareToggle,
+ );
+ }
+ } else {
+ perf.miss(key);
+ return makeResponseCacheable(
+ req,
+ res,
+ next,
+ key,
+ duration,
+ strDuration,
+ middlewareToggle,
+ );
+ }
+ };
+
+ cache.options = options;
+
+ return cache;
+ };
+
+ this.options = function (options) {
+ if (options) {
+ Object.assign(globalOptions, options);
+ syncOptions();
+
+ if ('defaultDuration' in options) {
+ // Convert the default duration to a number in milliseconds (if needed)
+ globalOptions.defaultDuration = parseDuration(
+ globalOptions.defaultDuration,
+ 3600000,
+ );
+ }
+
+ if (globalOptions.trackPerformance) {
+ debug(
+ 'WARNING: using trackPerformance flag can cause high memory usage!',
+ );
+ }
+
+ return this;
+ } else {
+ return globalOptions;
+ }
+ };
+
+ this.resetIndex = function () {
+ index = {
+ all: [],
+ groups: {},
+ };
+ };
+
+ this.newInstance = function (config) {
+ var instance = new ApiCache();
+
+ if (config) {
+ instance.options(config);
+ }
+
+ return instance;
+ };
+
+ this.clone = function () {
+ return this.newInstance(this.options());
+ };
+
+ // initialize index
+ this.resetIndex();
+}
+
+module.exports = new ApiCache();
diff --git a/napi/util/crypto.js b/napi/util/crypto.js
new file mode 100644
index 0000000..de80e15
--- /dev/null
+++ b/napi/util/crypto.js
@@ -0,0 +1,67 @@
+const crypto = require('crypto');
+const iv = Buffer.from('0102030405060708');
+const presetKey = Buffer.from('0CoJUm6Qyw8W8jud');
+const linuxapiKey = Buffer.from('rFgB&h#%2?^eDg:Q');
+const base62 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+const publicKey =
+ '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDgtQn2JZ34ZC28NWYpAUd98iZ37BUrX/aKzmFbt7clFSs6sXqHauqKWqdtLkF2KexO40H1YTX8z2lSgBBOAxLsvaklV8k4cBFK9snQXE9/DDaFt6Rr7iVZMldczhC0JNgTz+SHXT6CBHuX3e9SdB1Ua44oncaTWz7OBGLbCiK45wIDAQAB\n-----END PUBLIC KEY-----';
+const eapiKey = 'e82ckenh8dichen8';
+
+const aesEncrypt = (buffer, mode, key, iv) => {
+ const cipher = crypto.createCipheriv('aes-128-' + mode, key, iv);
+ return Buffer.concat([cipher.update(buffer), cipher.final()]);
+};
+
+const rsaEncrypt = (buffer, key) => {
+ buffer = Buffer.concat([Buffer.alloc(128 - buffer.length), buffer]);
+ return crypto.publicEncrypt(
+ { key: key, padding: crypto.constants.RSA_NO_PADDING },
+ buffer,
+ );
+};
+
+const weapi = (object) => {
+ const text = JSON.stringify(object);
+ const secretKey = crypto
+ .randomBytes(16)
+ .map((n) => base62.charAt(n % 62).charCodeAt());
+ return {
+ params: aesEncrypt(
+ Buffer.from(
+ aesEncrypt(Buffer.from(text), 'cbc', presetKey, iv).toString('base64'),
+ ),
+ 'cbc',
+ secretKey,
+ iv,
+ ).toString('base64'),
+ encSecKey: rsaEncrypt(secretKey.reverse(), publicKey).toString('hex'),
+ };
+};
+
+const linuxapi = (object) => {
+ const text = JSON.stringify(object);
+ return {
+ eparams: aesEncrypt(Buffer.from(text), 'ecb', linuxapiKey, '')
+ .toString('hex')
+ .toUpperCase(),
+ };
+};
+
+const eapi = (url, object) => {
+ const text = typeof object === 'object' ? JSON.stringify(object) : object;
+ const message = `nobody${url}use${text}md5forencrypt`;
+ const digest = crypto.createHash('md5').update(message).digest('hex');
+ const data = `${url}-36cd479b6b5-${text}-36cd479b6b5-${digest}`;
+ return {
+ params: aesEncrypt(Buffer.from(data), 'ecb', eapiKey, '')
+ .toString('hex')
+ .toUpperCase(),
+ };
+};
+
+const decrypt = (cipherBuffer) => {
+ const decipher = crypto.createDecipheriv('aes-128-ecb', eapiKey, '');
+ return Buffer.concat([decipher.update(cipherBuffer), decipher.final()]);
+};
+
+module.exports = { weapi, linuxapi, eapi, decrypt };
diff --git a/napi/util/index.js b/napi/util/index.js
new file mode 100644
index 0000000..6241c2c
--- /dev/null
+++ b/napi/util/index.js
@@ -0,0 +1,17 @@
+module.exports = {
+ toBoolean(val) {
+ if (typeof val === 'boolean') return val;
+ if (val === '') return val;
+ return val === 'true' || val == '1';
+ },
+ cookieToJson(cookie) {
+ if (!cookie) return {};
+ let cookieArr = cookie.split(';');
+ let obj = {};
+ cookieArr.forEach((i) => {
+ let arr = i.split('=');
+ obj[arr[0]] = arr[1];
+ });
+ return obj;
+ },
+};
diff --git a/napi/util/memory-cache.js b/napi/util/memory-cache.js
new file mode 100644
index 0000000..02e735a
--- /dev/null
+++ b/napi/util/memory-cache.js
@@ -0,0 +1,63 @@
+function MemoryCache() {
+ this.cache = {};
+ this.size = 0;
+}
+
+MemoryCache.prototype.add = function (key, value, time, timeoutCallback) {
+ var old = this.cache[key];
+ var instance = this;
+
+ var entry = {
+ value: value,
+ expire: time + Date.now(),
+ timeout: setTimeout(function () {
+ instance.delete(key);
+ return (
+ timeoutCallback &&
+ typeof timeoutCallback === 'function' &&
+ timeoutCallback(value, key)
+ );
+ }, time),
+ };
+
+ this.cache[key] = entry;
+ this.size = Object.keys(this.cache).length;
+
+ return entry;
+};
+
+MemoryCache.prototype.delete = function (key) {
+ var entry = this.cache[key];
+
+ if (entry) {
+ clearTimeout(entry.timeout);
+ }
+
+ delete this.cache[key];
+
+ this.size = Object.keys(this.cache).length;
+
+ return null;
+};
+
+MemoryCache.prototype.get = function (key) {
+ var entry = this.cache[key];
+
+ return entry;
+};
+
+MemoryCache.prototype.getValue = function (key) {
+ var entry = this.get(key);
+
+ return entry && entry.value;
+};
+
+MemoryCache.prototype.clear = function () {
+ Object.keys(this.cache).forEach(function (key) {
+ this.delete(key);
+ }, this);
+
+ return true;
+};
+
+module.exports = MemoryCache;
diff --git a/napi/util/request.js b/napi/util/request.js
new file mode 100644
index 0000000..84d448d
--- /dev/null
+++ b/napi/util/request.js
@@ -0,0 +1,177 @@
+const encrypt = require('./crypto');
+const axios = require('axios');
+const queryString = require('querystring');
+const PacProxyAgent = require('pac-proxy-agent');
+const http = require('http');
+const https = require('https');
+const tunnel = require('tunnel');
+const qs = require('url');
+// request.debug = true // 开启可看到更详细信息
+
+const chooseUserAgent = (ua = false) => {
+ const userAgentList = {
+ mobile: [
+ // iOS 13.5.1 14.0 beta with safari
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1',
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.',
+ // iOS with qq micromsg
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML like Gecko) Mobile/14A456 QQ/6.5.7.408 V1_IPH_SQ_6.5.7_1_APP_A Pixel/750 Core/UIWebView NetType/4G Mem/103',
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f27) NetType/WIFI Language/zh',
+ // Android -> Huawei Xiaomi
+ 'Mozilla/5.0 (Linux; Android 9; PCT-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.64 HuaweiBrowser/10.0.3.311 Mobile Safari/537.36',
+ 'Mozilla/5.0 (Linux; U; Android 9; zh-cn; Redmi Note 8 Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/12.5.22',
+ // Android + qq micromsg
+ 'Mozilla/5.0 (Linux; Android 10; YAL-AL00 Build/HUAWEIYAL-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2581 MMWEBSDK/200801 Mobile Safari/537.36 MMWEBID/3027 MicroMessenger/7.0.18.1740(0x27001235) Process/toolsmp WeChat/arm64 NetType/WIFI Language/zh_CN ABI/arm64',
+ 'Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BKK-AL10 Build/HONORBKK-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/10.6 Mobile Safari/537.36',
+ ],
+ pc: [
+ // macOS 10.15.6 Firefox / Chrome / Safari
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0',
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36',
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15',
+ // Windows 10 Firefox / Chrome / Edge
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0',
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36',
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586',
+ // Linux 就算了
+ ],
+ };
+ let realUserAgentList =
+ userAgentList[ua] || userAgentList.mobile.concat(userAgentList.pc);
+ return ['mobile', 'pc', false].indexOf(ua) > -1
+ ? realUserAgentList[Math.floor(Math.random() * realUserAgentList.length)]
+ : ua;
+};
+const createRequest = (method, url, data, options) => {
+ return new Promise((resolve, reject) => {
+ let headers = { 'User-Agent': chooseUserAgent(options.ua) };
+ if (method.toUpperCase() === 'POST')
+ headers['Content-Type'] = 'application/x-www-form-urlencoded';
+ if (url.includes('music.163.com'))
+ headers['Referer'] = 'https://music.163.com';
+ if (options.realIP) headers['X-Real-IP'] = options.realIP;
+ // headers['X-Real-IP'] = '118.88.88.88'
+ if (typeof options.cookie === 'object')
+ headers['Cookie'] = Object.keys(options.cookie)
+ .map(
+ (key) =>
+ encodeURIComponent(key) +
+ '=' +
+ encodeURIComponent(options.cookie[key]),
+ )
+ .join('; ');
+ else if (options.cookie) headers['Cookie'] = options.cookie;
+
+ if (!headers['Cookie']) {
+ headers['Cookie'] = options.token || '';
+ }
+ if (options.crypto === 'weapi') {
+ let csrfToken = (headers['Cookie'] || '').match(/_csrf=([^(;|$)]+)/);
+ data.csrf_token = csrfToken ? csrfToken[1] : '';
+ data = encrypt.weapi(data);
+ url = url.replace(/\w*api/, 'weapi');
+ } else if (options.crypto === 'linuxapi') {
+ data = encrypt.linuxapi({
+ method: method,
+ url: url.replace(/\w*api/, 'api'),
+ params: data,
+ });
+ headers['User-Agent'] =
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36';
+ url = 'https://music.163.com/api/linux/forward';
+ } else if (options.crypto === 'eapi') {
+ const cookie = options.cookie || {};
+ const csrfToken = cookie['__csrf'] || '';
+ const header = {
+ osver: cookie.osver, //系统版本
+ deviceId: cookie.deviceId, //encrypt.base64.encode(imei + '\t02:00:00:00:00:00\t5106025eb79a5247\t70ffbaac7')
+ appver: cookie.appver || '6.1.1', // app版本
+ versioncode: cookie.versioncode || '140', //版本号
+ mobilename: cookie.mobilename, //设备model
+ buildver: cookie.buildver || Date.now().toString().substr(0, 10),
+ resolution: cookie.resolution || '1920x1080', //设备分辨率
+ __csrf: csrfToken,
+ os: cookie.os || 'android',
+ channel: cookie.channel,
+ requestId: `${Date.now()}_${Math.floor(Math.random() * 1000)
+ .toString()
+ .padStart(4, '0')}`,
+ };
+ if (cookie.MUSIC_U) header['MUSIC_U'] = cookie.MUSIC_U;
+ if (cookie.MUSIC_A) header['MUSIC_A'] = cookie.MUSIC_A;
+ headers['Cookie'] = Object.keys(header)
+ .map(
+ (key) =>
+ encodeURIComponent(key) + '=' + encodeURIComponent(header[key]),
+ )
+ .join('; ');
+ data.header = header;
+ data = encrypt.eapi(options.url, data);
+ url = url.replace(/\w*api/, 'eapi');
+ }
+
+ const answer = { status: 500, body: {}, cookie: [] };
+ const settings = {
+ method: method,
+ url: url,
+ headers: headers,
+ data: queryString.stringify(data),
+ httpAgent: new http.Agent({ keepAlive: true }),
+ httpsAgent: new https.Agent({ keepAlive: true }),
+ };
+
+ if (options.crypto === 'eapi') settings.encoding = null;
+
+ if (options.proxy) {
+ if (options.proxy.indexOf('pac') > -1) {
+ settings.httpAgent = new PacProxyAgent(options.proxy);
+ settings.httpsAgent = new PacProxyAgent(options.proxy);
+ } else {
+ var purl = qs.parse(options.proxy);
+ if (purl.hostname) {
+ const agent = tunnel.httpsOverHttp({
+ proxy: {
+ host: purl.hostname,
+ port: purl.port || 80,
+ },
+ });
+ settings.httpsAgent = agent;
+ settings.httpAgent = agent;
+ settings.proxy = false;
+ } else {
+ console.error('代理配置无效,不使用代理');
+ }
+ }
+ }
+
+ axios(settings)
+ .then((res) => {
+ const body = res.data;
+ answer.cookie = (res.headers['set-cookie'] || []).map((x) =>
+ x.replace(/\s*Domain=[^(;|$)]+;*/, ''),
+ );
+ try {
+ answer.body = body;
+ answer.status = answer.body.code || res.status;
+ if (answer.body.code === 502) {
+ answer.status = 200;
+ }
+ } catch (e) {
+ answer.body = body;
+ answer.status = res.status;
+ }
+
+ answer.status =
+ 100 < answer.status && answer.status < 600 ? answer.status : 400;
+ if (answer.status == 200) resolve(answer);
+ else reject(answer);
+ })
+ .catch((err) => {
+ answer.status = 502;
+ answer.body = { code: 502, msg: err };
+ reject(answer);
+ });
+ });
+};
+
+module.exports = createRequest;
diff --git a/package.json b/package.json
index ef94503..b3539b2 100644
--- a/package.json
+++ b/package.json
@@ -13,31 +13,38 @@
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps",
"prettier": "npx prettier --write ./src ./script",
- "napi:run": "cd ./NeteaseCloudMusicApi-master && npm run start",
+ "napi:run": "cd ./napi && npm run start",
"napi:pull": "node script/pull.js",
- "napi:install": "cd ./NeteaseCloudMusicApi-master && npm install",
+ "napi:install": "cd ./napi && npm install",
"napi:setup": "npm run napi:pull && npm run napi:install"
},
"main": "background.js",
"dependencies": {
- "@sentry/browser": "^5.27.0",
- "@sentry/integrations": "^5.27.0",
- "@sentry/tracing": "^5.27.0",
- "axios": "^0.20.0",
+ "apicache": "^1.5.3",
+ "axios": "^0.21.0",
+ "big-integer": "^1.6.48",
"core-js": "^3.6.5",
"crypto-js": "^4.0.0",
"dayjs": "^1.8.36",
+ "electron": "^10.1.4",
+ "electron-debug": "^3.1.0",
+ "electron-devtools-installer": "^3.1.1",
+ "electron-context-menu": "^2.3.0",
"electron-is-dev": "^1.2.0",
"electron-log": "^4.2.4",
"electron-updater": "^4.3.5",
+ "express": "^4.17.1",
+ "express-fileupload": "^1.2.0",
"extract-zip": "^2.0.1",
"howler": "^2.2.0",
"js-cookie": "^2.2.1",
"nprogress": "^0.2.0",
+ "pac-proxy-agent": "^4.1.0",
"plyr": "^3.6.2",
"prettier": "2.1.2",
"register-service-worker": "^1.7.1",
"svg-sprite-loader": "^5.0.0",
+ "tunnel": "^0.0.6",
"vue": "^2.6.11",
"vue-analytics": "^5.22.1",
"vue-electron": "^1.0.6",
@@ -49,15 +56,15 @@
"vuex-electron": "^1.0.3"
},
"devDependencies": {
+ "@sentry/browser": "^5.27.0",
+ "@sentry/integrations": "^5.27.0",
+ "@sentry/tracing": "^5.27.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-pwa": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
- "electron": "^10.1.4",
- "electron-debug": "^3.1.0",
- "electron-devtools-installer": "^3.1.1",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"husky": "^4.3.0",
diff --git a/public/img/icons/android-chrome-maskable-192x192.png b/public/img/icons/android-chrome-maskable-192x192.png
deleted file mode 100644
index 791e9c8..0000000
Binary files a/public/img/icons/android-chrome-maskable-192x192.png and /dev/null differ
diff --git a/public/img/icons/android-chrome-maskable-512x512.png b/public/img/icons/android-chrome-maskable-512x512.png
deleted file mode 100644
index 5f2098e..0000000
Binary files a/public/img/icons/android-chrome-maskable-512x512.png and /dev/null differ
diff --git a/src/background.js b/src/background.js
index 4ea6e34..f8c4da1 100644
--- a/src/background.js
+++ b/src/background.js
@@ -1,12 +1,21 @@
"use strict";
-const { exec } = require("child_process");
-// const fs = require('fs')
-import { app, protocol, BrowserWindow } from "electron";
+
+import path from 'path'
+// import { autoUpdater } from "electron-updater"
+import {
+ app,
+ protocol,
+ BrowserWindow,
+ ipcMain,
+ dialog,
+ globalShortcut,
+} from "electron";
import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
-const isDevelopment = process.env.NODE_ENV !== "production";
+
// maybe use for modify app menu
-// const contextMenu = require('electron-context-menu');
+// import contextMenu from 'electron-context-menu'
+const isDevelopment = process.env.NODE_ENV !== "production";
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
@@ -18,36 +27,19 @@ protocol.registerSchemesAsPrivileged([
]);
function createWindow() {
- console.log("Node Version: ", process.version);
- const napi = exec("npm run napi:run");
- let scriptOutput = "";
- napi.stdout.setEncoding('utf8');
- napi.stdout.on('data', (data) => {
- console.log('napi: ' + data);
- data = data.toString();
- scriptOutput += data + '\n';
- // TODO write file with stream
- // const log = fs.createWriteStream(__dirname, '/tmp/' + +new Date + '.log')
- // log.write(scriptOutput)
- });
- // napi.stdout.on('error', (err) => {
- // console.log('napi error: ' + err);
- // data = err.toString();
- // scriptOutput += data + '\n';
- // const log = fs.createWriteStream(__dirname, '/tmp/' + +new Date + 'error.log')
- // log.write(scriptOutput)
- // });
-
- // Create the browser window.
+ require('./electron/services')
+
+// Create the browser window.
win = new BrowserWindow({
- width: 1920,
+ width: 1153,
height: 768,
webPreferences: {
webSecurity: false,
- // Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: true,
},
+ icon: path.join(__static, "./img/icons/android-chrome-512x512.png"),
+ preload: path.join(__dirname, "./electron/preload.js"),
});
if (process.env.WEBPACK_DEV_SERVER_URL) {
@@ -58,7 +50,7 @@ function createWindow() {
createProtocol("app");
// Load the index.html when not in development
win.loadURL("app://./index.html");
- win.webContents.openDevTools();
+ // autoUpdater.checkForUpdatesAndNotify()
}
win.on("closed", () => {
@@ -95,9 +87,38 @@ app.on("ready", async () => {
console.error("Vue Devtools failed to install:", e.toString());
}
}
+ // Register shortcut for debug
+ globalShortcut.register("CommandOrControl+K", function () {
+ win.webContents.openDevTools();
+ });
createWindow();
});
+ipcMain.on("close", () => {
+ win.close();
+ app.quit();
+});
+ipcMain.on("minimize", () => {
+ win.minimize();
+});
+
+// autoUpdater.on("checking-for-update", () => {});
+// autoUpdater.on("update-available", info => {
+// console.log(info);
+// dialog.showMessageBox({
+// title: "新版本发布",
+// message: "有新内容更新,稍后将重新为您安装",
+// buttons: ["确定"],
+// type: "info",
+// noLink: true
+// });
+// });
+
+// autoUpdater.on("update-downloaded", info => {
+// console.log(info);
+// autoUpdater.quitAndInstall();
+// });
+
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === "win32") {
@@ -112,3 +133,19 @@ if (isDevelopment) {
});
}
}
+
+// Make sure the app is singleton.
+function initialize() {
+ const shouldQuit = !app.requestSingleInstanceLock();
+ if (shouldQuit) return app.quit();
+ // loadComponent()
+}
+
+/**
+ * 注册主线程文件里的所有js
+ */
+// function loadComponent () {
+// require('./electron/menu.js')
+// }
+
+initialize();
diff --git a/src/electron/command.js b/src/electron/command.js
new file mode 100644
index 0000000..c71471c
--- /dev/null
+++ b/src/electron/command.js
@@ -0,0 +1,116 @@
+"use strict";
+
+import { app, ipcMain, Menu, MenuItem, BrowserWindow, globalShortcut } from 'electron'
+
+let loginWindow, senders;
+
+function openWindow(url) {
+ const win = new BrowserWindow({
+ height: 500,
+ width: 350,
+ useContentSize: true,
+ transparent: false,
+ frame: false,
+ darkTheme: true,
+ backgroundColor: "#FFF",
+ });
+
+ win.loadURL(url);
+
+ win.on("closed", () => {
+ loginWindow = null;
+ });
+
+ return win;
+}
+
+const menu = new Menu();
+
+const settingsMenu = {
+ playMenu: function () {
+ const settings = {
+ paly: {
+ label: "播放",
+ click: function () {
+ senders.send("play-start");
+ },
+ },
+ addPlayList: {
+ label: "添加到播放列表",
+ click: function () {
+ senders.send("add-play-list");
+ },
+ },
+ collect: {
+ label: "收藏",
+ submenu: [
+ {
+ label: "创建新歌单",
+ click: function () {
+ senders.send("i-like-star");
+ },
+ },
+ ],
+ },
+ share: {
+ label: "分享",
+ },
+ copyLink: {
+ label: "复制链接",
+ },
+ };
+ menu.append(new MenuItem(settings.paly));
+ menu.append(new MenuItem(settings.addPlayList));
+ menu.append(new MenuItem({ type: "separator" }));
+ menu.append(new MenuItem(settings.collect));
+ menu.append(new MenuItem(settings.share));
+ menu.append(new MenuItem(settings.copyLink));
+ },
+};
+
+export function command(mainWindow, winURL) {
+ // 显示播放菜单
+ settingsMenu.playMenu();
+ // 接收显示菜单指令
+ ipcMain.on("show-content-menu", (event) => {
+ senders = event.sender;
+ const win = BrowserWindow.fromWebContents(senders);
+ menu.popup(win);
+ });
+ // 设置app名称
+ app.setName("网易云音乐App");
+ // 关闭window窗口
+ ipcMain.on("window-close", (event) => {
+ app.quit();
+ });
+ // 最大化window窗口
+ ipcMain.on("window-max", (event) => {
+ if (mainWindow.isMaximized()) {
+ mainWindow.unmaximize();
+ } else {
+ mainWindow.maximize();
+ }
+ });
+ // 最小化window窗口
+ ipcMain.on("window-min", (event) => {
+ if (!mainWindow.isMinimized()) {
+ mainWindow.minimize();
+ }
+ });
+ // 新建登录窗口
+ ipcMain.on("open-login-window", (event, url) => {
+ if (loginWindow) {
+ loginWindow.focus();
+ } else {
+ loginWindow = openWindow(url);
+ }
+ });
+ // 关闭登录窗口
+ ipcMain.on("close-login-window", (event) => {
+ loginWindow.close();
+ });
+ // 触发调试 Shift+i
+ globalShortcut.register("Shift+i", () => {
+ require("electron-debug")({ showDevTools: true });
+ });
+}
diff --git a/src/electron/menu.js b/src/electron/menu.js
new file mode 100644
index 0000000..7e2713f
--- /dev/null
+++ b/src/electron/menu.js
@@ -0,0 +1,161 @@
+const { Menu, app } = require("electron");
+
+const version = app.getVersion();
+
+let win;
+let updateSource = "menu"; // 更新事件触发来源 menu:通过菜单触发 vue:通过vue页面触发
+let template = [
+ {
+ label: "编辑",
+ submenu: [
+ {
+ label: "剪切",
+ accelerator: (() => {
+ if (process.platform === "darwin") {
+ return "CmdOrCtrl+X";
+ } else {
+ return "Ctrl+X";
+ }
+ })(),
+ role: "cut",
+ },
+ {
+ label: "复制",
+ accelerator: (() => {
+ if (process.platform === "darwin") {
+ return "CmdOrCtrl+C";
+ } else {
+ return "Ctrl+C";
+ }
+ })(),
+ role: "copy",
+ },
+ {
+ label: "粘贴",
+ accelerator: (() => {
+ if (process.platform === "darwin") {
+ return "CmdOrCtrl+V";
+ } else {
+ return "Ctrl+V";
+ }
+ })(),
+ role: "paste",
+ },
+ ],
+ },
+ {
+ label: "工具",
+ submenu: [
+ {
+ label: "刷新",
+ accelerator: (() => {
+ if (process.platform === "darwin") {
+ return "CmdOrCtrl+R";
+ } else {
+ return "F5";
+ }
+ })(),
+ click: (item, focusedWindow) => {
+ if (focusedWindow) {
+ focusedWindow.reload();
+ }
+ },
+ },
+ {
+ label: "全屏",
+ accelerator: (() => {
+ if (process.platform === "darwin") {
+ return "Ctrl+Command+F";
+ } else {
+ return "F11";
+ }
+ })(),
+ click: (item, focusedWindow) => {
+ if (focusedWindow) {
+ focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
+ }
+ },
+ },
+ {
+ label: "检查",
+ accelerator: "F12",
+ click: (item, focusedWindow) => {
+ if (focusedWindow) {
+ focusedWindow.toggleDevTools();
+ }
+ },
+ },
+ ],
+ },
+];
+
+function findReopenMenuItem() {
+ const menu = Menu.getApplicationMenu();
+ if (!menu) return;
+
+ let reopenMenuItem;
+ menu.items.forEach((item) => {
+ if (item.submenu) {
+ item.submenu.items.forEach((item) => {
+ if (item.key === "reopenMenuItem") {
+ reopenMenuItem = item;
+ }
+ });
+ }
+ });
+ return reopenMenuItem;
+}
+
+// mac 添加退出
+if (process.platform === "darwin") {
+ const name = app.getName();
+ template.unshift({
+ label: name + " v" + version,
+ submenu: [
+ {
+ label: "退出",
+ accelerator: "Command+Q",
+ click: () => {
+ app.quit();
+ },
+ },
+ ],
+ });
+}
+// win 添加更新菜单
+if (process.platform === "win32") {
+ template.push({
+ label: "帮助",
+ submenu: [
+ {
+ label: `当前版本 v${version}`,
+ enabled: false,
+ },
+ {
+ label: "检查更新",
+ accelerator: "Ctrl+U",
+ click: (item, focusedWindow) => {
+ // 执行自动更新检查
+ win = focusedWindow;
+ updateSource = "menu";
+ autoUpdater.checkForUpdates();
+ },
+ },
+ ],
+ });
+}
+
+app.on('ready', () => {
+ const menu = Menu.buildFromTemplate(template)
+ Menu.setApplicationMenu(menu)
+})
+
+app.on('browser-window-created', () => {
+ let reopenMenuItem = findReopenMenuItem()
+ if (reopenMenuItem) reopenMenuItem.enabled = false
+})
+
+app.on('window-all-closed', () => {
+ let reopenMenuItem = findReopenMenuItem()
+ if (reopenMenuItem) reopenMenuItem.enabled = true
+})
diff --git a/src/electron/preload.js b/src/electron/preload.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/electron/services.js b/src/electron/services.js
new file mode 100644
index 0000000..9f2d783
--- /dev/null
+++ b/src/electron/services.js
@@ -0,0 +1,61 @@
+const express = require("express");
+const path = require("path");
+const bodyParser = require('body-parser')
+const cache = require('../../napi/util/apicache').middleware
+const fileUpload = require('express-fileupload')
+
+import routes from "../../napi/routes";
+
+// Integrate API
+const app = express()
+
+// CORS & Preflight request
+app.use((req, res, next) => {
+ if (req.path !== '/' && !req.path.includes('.')) {
+ res.set({
+ 'Access-Control-Allow-Credentials': true,
+ 'Access-Control-Allow-Origin': req.headers.origin || '*',
+ 'Access-Control-Allow-Headers': 'X-Requested-With,Content-Type',
+ 'Access-Control-Allow-Methods': 'PUT,POST,GET,DELETE,OPTIONS',
+ 'Content-Type': 'application/json; charset=utf-8',
+ })
+ }
+ req.method === 'OPTIONS' ? res.status(204).end() : next()
+})
+
+// cookie parser
+app.use((req, res, next) => {
+ req.cookies = {}
+ ;(req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => {
+ let crack = pair.indexOf('=')
+ if (crack < 1 || crack == pair.length - 1) return
+ req.cookies[
+ decodeURIComponent(pair.slice(0, crack)).trim()
+ ] = decodeURIComponent(pair.slice(crack + 1)).trim()
+ })
+ next()
+})
+
+// body parser
+app.use(bodyParser.json())
+app.use(bodyParser.urlencoded({ extended: false }))
+
+app.use(fileUpload())
+
+// static
+// app.use(express.static(path.join(__dirname, 'public')))
+
+// cache
+app.use(cache('2 minutes', (req, res) => res.statusCode === 200))
+// router
+
+Object.keys(routes).forEach(route => {
+ app.use(route, routes[route])
+})
+
+const port = process.env.PORT || 3000
+const host = process.env.HOST || ''
+
+app.server = app.listen(port, host, () => {
+ console.log(`server running @ http://${host ? host : 'localhost'}:${port}`)
+})
\ No newline at end of file
diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js
index 1473a0a..b8a8c97 100644
--- a/src/registerServiceWorker.js
+++ b/src/registerServiceWorker.js
@@ -2,7 +2,7 @@
import { register } from "register-service-worker";
-if (process.env.NODE_ENV === "production") {
+if (process.env.NODE_ENV === "production" && process.env.IS_ELECTRON === 'undefined') {
register(`${process.env.BASE_URL}service-worker.js`, {
ready() {
console.log(
diff --git a/vue.config.js b/vue.config.js
index c08614c..0f10e28 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,5 +1,5 @@
const path = require("path");
-const CopywebpackPlugin = require('copy-webpack-plugin')
+const CopyPlugin = require('copy-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir);
}
@@ -50,72 +50,56 @@ module.exports = {
pluginOptions: {
// electron-builder的配置文件
electronBuilder: {
+ preload: 'src/electron/preload.js',
builderOptions: {
- // files: [
- // {
- // 'filter': ['**/*']
- // }
- // ],
- // extraFiles: ['./extensions/'],
// 应用名称
productName: 'Yes Play Music',
// 版权
copyright: 'Copyright © YesPlayMusic',
compression: "maximum",
- // 是否打包加密
+ publish: ["github"],
+ // Compress app using 'electron/asar'
asar: true,
- // // 项目打包生成的文件目录
- // directories: {
- // output: 'build'
- // },
- // window的icon头标
+
+ // 项目打包生成的文件目录
+ directories: {
+ output: 'dist_electron'
+ },
+ // window 的 icon 头标
win: {
icon: 'public/favicon.ico'
},
// 是否静默安装
nsis: {
+ // 是否一键安装,建议为 false,可以让用户点击下一步、下一步、下一步的形式安装程序,如果为true,当用户双击构建好的程序,自动安装程序并打开,即:一键安装
oneClick: false,
+ // 允许修改安装目录,建议为 true,是否允许用户改变安装目录,默认是不允许
allowToChangeInstallationDirectory: true
},
// 集成 nodejs, https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration
// nodeIntegration: true
},
+ // 主线程的配置文件
chainWebpackMainProcess: config => {
- // console.log(config)
- let outputDir = 'dist_electron/bundled'
- config.plugin('copy').use(CopywebpackPlugin, [
- [
- {
- from: path.resolve(__dirname, './NeteaseCloudMusicApi-master'),
- to: path.join(__dirname, outputDir, 'NeteaseCloudMusicApi-master')
- }
- ]
- ])
- }
+ config.plugin('define').tap((args) => {
+ args[0]['IS_ELECTRON'] = true
+ return args
+ })
+ },
// 渲染线程的配置文件
- // chainWebpackRendererProcess: config => {
- // // 渲染线程的一些其他配置
- // // Chain webpack config for electron renderer process only
- // // The following example will set IS_ELECTRON to true in your app
- // config.plugin('define').tap((args) => {
- // args[0]['IS_ELECTRON'] = true
- // return args
- // })
- // },
+ chainWebpackRendererProcess: config => {
+ // 渲染线程的一些其他配置
+ // Chain webpack config for electron renderer process only
+ // The following example will set IS_ELECTRON to true in your app
+ config.plugin('define').tap((args) => {
+ args[0]['IS_ELECTRON'] = true
+ return args
+ })
+ },
// 主入口文件
// mainProcessFile: 'src/main.js',
- // mainProcessWatch: [],
+ mainProcessWatch: ['../napi/routes.js'],
// mainProcessArgs: []
}
- },
- // 打包时不生成.map文件,减少体积,加快速度如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
- productionSourceMap: false,
- // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。
- assetsDir: 'src/renderer/static',
- // 跨域配置
- devServer: {
- disableHostCheck: true
- },
- // css 样式
- css: {}
+ }
};
diff --git a/yarn.lock b/yarn.lock
index 590482f..f8b5e98 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1050,6 +1050,11 @@
dependencies:
defer-to-connect "^1.0.1"
+"@tootallnate/once@1":
+ version "1.1.2"
+ resolved "https://registry.npm.taobao.org/@tootallnate/once/download/@tootallnate/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
+ integrity sha1-zLkURTYBeaBOf+av94wA/8Hur4I=
+
"@types/anymatch@*":
version "1.3.1"
resolved "https://registry.npm.taobao.org/@types/anymatch/download/@types/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
@@ -1732,6 +1737,13 @@ address@^1.1.2:
resolved "https://registry.npm.taobao.org/address/download/address-1.1.2.tgz#bf1116c9c758c51b7a933d296b72c221ed9428b6"
integrity sha1-vxEWycdYxRt6kz0pa3LCIe2UKLY=
+agent-base@6:
+ version "6.0.2"
+ resolved "https://registry.npm.taobao.org/agent-base/download/agent-base-6.0.2.tgz?cache=0&sync_timestamp=1603480100923&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fagent-base%2Fdownload%2Fagent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
+ integrity sha1-Sf/1hXfP7j83F2/qtMIuAPhtf3c=
+ dependencies:
+ debug "4"
+
aggregate-error@^3.0.0:
version "3.1.0"
resolved "https://registry.npm.taobao.org/aggregate-error/download/aggregate-error-3.1.0.tgz?cache=0&sync_timestamp=1598049717562&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Faggregate-error%2Fdownload%2Faggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a"
@@ -1860,6 +1872,11 @@ anymatch@~3.1.1:
normalize-path "^3.0.0"
picomatch "^2.0.4"
+apicache@^1.5.3:
+ version "1.5.3"
+ resolved "https://registry.npm.taobao.org/apicache/download/apicache-1.5.3.tgz#8977b358bf7d579d55fe3d183c907ae5dbcfb357"
+ integrity sha1-iXezWL99V51V/j0YPJB65dvPs1c=
+
app-builder-bin@3.5.10:
version "3.5.10"
resolved "https://registry.npm.taobao.org/app-builder-bin/download/app-builder-bin-3.5.10.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fapp-builder-bin%2Fdownload%2Fapp-builder-bin-3.5.10.tgz#4a7f9999fccc0c435b6284ae1366bc76a17c4a7d"
@@ -1987,11 +2004,23 @@ assign-symbols@^1.0.0:
resolved "https://registry.npm.taobao.org/assign-symbols/download/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=
+ast-types@^0.13.2:
+ version "0.13.4"
+ resolved "https://registry.npm.taobao.org/ast-types/download/ast-types-0.13.4.tgz?cache=0&sync_timestamp=1599935985242&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fast-types%2Fdownload%2Fast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782"
+ integrity sha1-7g13s0MmOWXsw/ti2hbnIisrZ4I=
+ dependencies:
+ tslib "^2.0.1"
+
astral-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.npm.taobao.org/astral-regex/download/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
integrity sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=
+astral-regex@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.npm.taobao.org/astral-regex/download/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
+ integrity sha1-SDFDxWeu7UeFdZwIZXhtx319LjE=
+
async-each@^1.0.1:
version "1.0.3"
resolved "https://registry.npm.taobao.org/async-each/download/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf"
@@ -2057,10 +2086,10 @@ aws4@^1.8.0:
resolved "https://registry.npm.taobao.org/aws4/download/aws4-1.10.1.tgz?cache=0&sync_timestamp=1597236947743&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Faws4%2Fdownload%2Faws4-1.10.1.tgz#e1e82e4f3e999e2cfd61b161280d16a111f86428"
integrity sha1-4eguTz6Zniz9YbFhKA0WoRH4ZCg=
-axios@^0.20.0:
- version "0.20.0"
- resolved "https://registry.yarnpkg.com/axios/-/axios-0.20.0.tgz#057ba30f04884694993a8cd07fa394cff11c50bd"
- integrity sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==
+axios@^0.21.0:
+ version "0.21.0"
+ resolved "https://registry.npm.taobao.org/axios/download/axios-0.21.0.tgz#26df088803a2350dff2c27f96fef99fe49442aca"
+ integrity sha1-Jt8IiAOiNQ3/LCf5b++Z/klEKso=
dependencies:
follow-redirects "^1.10.0"
@@ -2172,6 +2201,11 @@ bfj@^6.1.1:
hoopy "^0.1.4"
tryer "^1.0.1"
+big-integer@^1.6.48:
+ version "1.6.48"
+ resolved "https://registry.npm.taobao.org/big-integer/download/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e"
+ integrity sha1-j9iL0WMsukocjD49cVnwi7lbS54=
+
big.js@^3.1.3:
version "3.2.0"
resolved "https://registry.npm.taobao.org/big.js/download/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"
@@ -2447,6 +2481,13 @@ builtin-status-codes@^3.0.0:
resolved "https://registry.npm.taobao.org/builtin-status-codes/download/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=
+busboy@^0.3.1:
+ version "0.3.1"
+ resolved "https://registry.npm.taobao.org/busboy/download/busboy-0.3.1.tgz#170899274c5bf38aae27d5c62b71268cd585fd1b"
+ integrity sha1-FwiZJ0xb84quJ9XGK3EmjNWF/Rs=
+ dependencies:
+ dicer "0.3.0"
+
bytes@3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/bytes/download/bytes-3.0.0.tgz?cache=0&sync_timestamp=1589682741197&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbytes%2Fdownload%2Fbytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
@@ -2830,6 +2871,14 @@ cli-spinners@^2.0.0:
resolved "https://registry.npm.taobao.org/cli-spinners/download/cli-spinners-2.4.0.tgz#c6256db216b878cfba4720e719cec7cf72685d7f"
integrity sha1-xiVtsha4eM+6RyDnGc7Hz3JoXX8=
+cli-truncate@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.npm.taobao.org/cli-truncate/download/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7"
+ integrity sha1-w54ovwXtzeW+O5iZKiLe7Vork8c=
+ dependencies:
+ slice-ansi "^3.0.0"
+ string-width "^4.2.0"
+
cli-width@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/cli-width/download/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6"
@@ -3455,6 +3504,11 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
+data-uri-to-buffer@3:
+ version "3.0.1"
+ resolved "https://registry.npm.taobao.org/data-uri-to-buffer/download/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636"
+ integrity sha1-WUuJc5OMW8LDMEZTV4U0GrxPNjY=
+
dayjs@^1.8.36:
version "1.8.36"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.8.36.tgz#be36e248467afabf8f5a86bae0de0cdceecced50"
@@ -3472,6 +3526,13 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
dependencies:
ms "2.0.0"
+debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
+ version "4.2.0"
+ resolved "https://registry.npm.taobao.org/debug/download/debug-4.2.0.tgz?cache=0&sync_timestamp=1600502894812&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1"
+ integrity sha1-fxUPk5IOlMWPVXTC/QGjEQ7/5/E=
+ dependencies:
+ ms "2.1.2"
+
debug@^3.1.1, debug@^3.2.5:
version "3.2.6"
resolved "https://registry.npm.taobao.org/debug/download/debug-3.2.6.tgz?cache=0&sync_timestamp=1600502894812&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
@@ -3479,13 +3540,6 @@ debug@^3.1.1, debug@^3.2.5:
dependencies:
ms "^2.1.1"
-debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
- version "4.2.0"
- resolved "https://registry.npm.taobao.org/debug/download/debug-4.2.0.tgz?cache=0&sync_timestamp=1600502894812&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1"
- integrity sha1-fxUPk5IOlMWPVXTC/QGjEQ7/5/E=
- dependencies:
- ms "2.1.2"
-
debug@^4.3.0:
version "4.3.0"
resolved "https://registry.npm.taobao.org/debug/download/debug-4.3.0.tgz?cache=0&sync_timestamp=1600502894812&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.3.0.tgz#efa41cbf14fc9448075367fdaaddf82376da211e"
@@ -3603,6 +3657,15 @@ define-property@^2.0.2:
is-descriptor "^1.0.2"
isobject "^3.0.1"
+degenerator@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.npm.taobao.org/degenerator/download/degenerator-2.2.0.tgz#49e98c11fa0293c5b26edfbb52f15729afcdb254"
+ integrity sha1-SemMEfoCk8Wybt+7UvFXKa/NslQ=
+ dependencies:
+ ast-types "^0.13.2"
+ escodegen "^1.8.1"
+ esprima "^4.0.0"
+
del@^4.1.1:
version "4.1.1"
resolved "https://registry.npm.taobao.org/del/download/del-4.1.1.tgz?cache=0&sync_timestamp=1589682730753&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdel%2Fdownload%2Fdel-4.1.1.tgz#9e8f117222ea44a31ff3a156c049b99052a9f0b4"
@@ -3644,6 +3707,13 @@ detect-node@^2.0.4:
resolved "https://registry.npm.taobao.org/detect-node/download/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c"
integrity sha1-AU7o+PZpxcWAI9pkuBecCDooxGw=
+dicer@0.3.0:
+ version "0.3.0"
+ resolved "https://registry.npm.taobao.org/dicer/download/dicer-0.3.0.tgz#eacd98b3bfbf92e8ab5c2fdb71aaac44bb06b872"
+ integrity sha1-6s2Ys7+/kuirXC/bcaqsRLsGuHI=
+ dependencies:
+ streamsearch "0.1.2"
+
diffie-hellman@^5.0.0:
version "5.0.3"
resolved "https://registry.npm.taobao.org/diffie-hellman/download/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
@@ -3861,6 +3931,15 @@ electron-builder@^22.2.0:
update-notifier "^4.1.1"
yargs "^16.0.3"
+electron-context-menu@^2.3.0:
+ version "2.3.0"
+ resolved "https://registry.npm.taobao.org/electron-context-menu/download/electron-context-menu-2.3.0.tgz#d9af9733b19a76c78c413d8eb7b00b1ae1ead356"
+ integrity sha1-2a+XM7GadseMQT2Ot7ALGuHq01Y=
+ dependencies:
+ cli-truncate "^2.0.0"
+ electron-dl "^3.0.0"
+ electron-is-dev "^1.0.1"
+
electron-debug@^3.1.0:
version "3.1.0"
resolved "https://registry.npm.taobao.org/electron-debug/download/electron-debug-3.1.0.tgz#0df17297487fa3c82344d810812853bf67f0bd69"
@@ -3878,12 +3957,21 @@ electron-devtools-installer@^3.1.1:
semver "^7.2.1"
unzip-crx-3 "^0.2.0"
+electron-dl@^3.0.0:
+ version "3.0.2"
+ resolved "https://registry.npm.taobao.org/electron-dl/download/electron-dl-3.0.2.tgz#302a46f9a449ddce720cb8e7f2a24c386e19a26c"
+ integrity sha1-MCpG+aRJ3c5yDLjn8qJMOG4Zomw=
+ dependencies:
+ ext-name "^5.0.0"
+ pupa "^2.0.1"
+ unused-filename "^2.1.0"
+
electron-is-accelerator@^0.1.0:
version "0.1.2"
resolved "https://registry.npm.taobao.org/electron-is-accelerator/download/electron-is-accelerator-0.1.2.tgz#509e510c26a56b55e17f863a4b04e111846ab27b"
integrity sha1-UJ5RDCala1Xhf4Y6SwThEYRqsns=
-electron-is-dev@^1.1.0, electron-is-dev@^1.2.0:
+electron-is-dev@^1.0.1, electron-is-dev@^1.1.0, electron-is-dev@^1.2.0:
version "1.2.0"
resolved "https://registry.npm.taobao.org/electron-is-dev/download/electron-is-dev-1.2.0.tgz#2e5cea0a1b3ccf1c86f577cee77363ef55deb05e"
integrity sha1-LlzqChs8zxyG9XfO53Nj71XesF4=
@@ -4125,6 +4213,18 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha1-FLqDpdNz49MR5a/KKc9b+tllvzQ=
+escodegen@^1.8.1:
+ version "1.14.3"
+ resolved "https://registry.npm.taobao.org/escodegen/download/escodegen-1.14.3.tgz?cache=0&sync_timestamp=1596669832613&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fescodegen%2Fdownload%2Fescodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503"
+ integrity sha1-TnuB+6YVgdyXWC7XjKt/Do1j9QM=
+ dependencies:
+ esprima "^4.0.1"
+ estraverse "^4.2.0"
+ esutils "^2.0.2"
+ optionator "^0.8.1"
+ optionalDependencies:
+ source-map "~0.6.1"
+
eslint-loader@^2.2.1:
version "2.2.1"
resolved "https://registry.npm.taobao.org/eslint-loader/download/eslint-loader-2.2.1.tgz#28b9c12da54057af0845e2a6112701a2f6bf8337"
@@ -4225,7 +4325,7 @@ espree@^6.1.2, espree@^6.2.1:
acorn-jsx "^5.2.0"
eslint-visitor-keys "^1.1.0"
-esprima@^4.0.0:
+esprima@^4.0.0, esprima@^4.0.1:
version "4.0.1"
resolved "https://registry.npm.taobao.org/esprima/download/esprima-4.0.1.tgz?cache=0&sync_timestamp=1589682833047&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fesprima%2Fdownload%2Fesprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=
@@ -4244,7 +4344,7 @@ esrecurse@^4.1.0, esrecurse@^4.3.0:
dependencies:
estraverse "^5.2.0"
-estraverse@^4.1.1:
+estraverse@^4.1.1, estraverse@^4.2.0:
version "4.3.0"
resolved "https://registry.npm.taobao.org/estraverse/download/estraverse-4.3.0.tgz?cache=0&sync_timestamp=1596642998635&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Festraverse%2Fdownload%2Festraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
integrity sha1-OYrT88WiSUi+dyXoPRGn3ijNvR0=
@@ -4364,6 +4464,13 @@ expand-brackets@^2.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"
+express-fileupload@^1.2.0:
+ version "1.2.0"
+ resolved "https://registry.npm.taobao.org/express-fileupload/download/express-fileupload-1.2.0.tgz#356c4dfd645be71ab9fb2f4e6d84eeb00d247979"
+ integrity sha1-NWxN/WRb5xq5+y9ObYTusA0keXk=
+ dependencies:
+ busboy "^0.3.1"
+
express@^4.16.3, express@^4.17.1:
version "4.17.1"
resolved "https://registry.npm.taobao.org/express/download/express-4.17.1.tgz?cache=0&sync_timestamp=1589682766604&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fexpress%2Fdownload%2Fexpress-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
@@ -4400,6 +4507,21 @@ express@^4.16.3, express@^4.17.1:
utils-merge "1.0.1"
vary "~1.1.2"
+ext-list@^2.0.0:
+ version "2.2.2"
+ resolved "https://registry.npm.taobao.org/ext-list/download/ext-list-2.2.2.tgz#0b98e64ed82f5acf0f2931babf69212ef52ddd37"
+ integrity sha1-C5jmTtgvWs8PKTG6v2khLvUt3Tc=
+ dependencies:
+ mime-db "^1.28.0"
+
+ext-name@^5.0.0:
+ version "5.0.0"
+ resolved "https://registry.npm.taobao.org/ext-name/download/ext-name-5.0.0.tgz#70781981d183ee15d13993c8822045c506c8f0a6"
+ integrity sha1-cHgZgdGD7hXROZPIgiBFxQbI8KY=
+ dependencies:
+ ext-list "^2.0.0"
+ sort-keys-length "^1.0.0"
+
extend-shallow@^2.0.1:
version "2.0.1"
resolved "https://registry.npm.taobao.org/extend-shallow/download/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
@@ -4554,6 +4676,11 @@ file-uri-to-path@1.0.0:
resolved "https://registry.npm.taobao.org/file-uri-to-path/download/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
integrity sha1-VTp7hEb/b2hDWcRF8eN6BdrMM90=
+file-uri-to-path@2:
+ version "2.0.0"
+ resolved "https://registry.npm.taobao.org/file-uri-to-path/download/file-uri-to-path-2.0.0.tgz#7b415aeba227d575851e0a5b0c640d7656403fba"
+ integrity sha1-e0Fa66In1XWFHgpbDGQNdlZAP7o=
+
filelist@^1.0.1:
version "1.0.1"
resolved "https://registry.npm.taobao.org/filelist/download/filelist-1.0.1.tgz#f10d1a3ae86c1694808e8f20906f43d4c9132dbb"
@@ -4812,6 +4939,14 @@ fsevents@~2.1.2:
resolved "https://registry.npm.taobao.org/fsevents/download/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e"
integrity sha1-+3OHA66NL5/pAMM4Nt3r7ouX8j4=
+ftp@^0.3.10:
+ version "0.3.10"
+ resolved "https://registry.npm.taobao.org/ftp/download/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d"
+ integrity sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=
+ dependencies:
+ readable-stream "1.1.x"
+ xregexp "2.0.0"
+
function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.npm.taobao.org/function-bind/download/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
@@ -4856,6 +4991,18 @@ get-stream@^5.0.0, get-stream@^5.1.0:
dependencies:
pump "^3.0.0"
+get-uri@3:
+ version "3.0.2"
+ resolved "https://registry.npm.taobao.org/get-uri/download/get-uri-3.0.2.tgz#f0ef1356faabc70e1f9404fa3b66b2ba9bfc725c"
+ integrity sha1-8O8TVvqrxw4flAT6O2ayupv8clw=
+ dependencies:
+ "@tootallnate/once" "1"
+ data-uri-to-buffer "3"
+ debug "4"
+ file-uri-to-path "2"
+ fs-extra "^8.1.0"
+ ftp "^0.3.10"
+
get-value@^2.0.3, get-value@^2.0.6:
version "2.0.6"
resolved "https://registry.npm.taobao.org/get-value/download/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
@@ -5276,17 +5423,7 @@ http-errors@1.7.2:
statuses ">= 1.5.0 < 2"
toidentifier "1.0.0"
-http-errors@~1.6.2:
- version "1.6.3"
- resolved "https://registry.npm.taobao.org/http-errors/download/http-errors-1.6.3.tgz?cache=0&sync_timestamp=1593407858306&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhttp-errors%2Fdownload%2Fhttp-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d"
- integrity sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=
- dependencies:
- depd "~1.1.2"
- inherits "2.0.3"
- setprototypeof "1.1.0"
- statuses ">= 1.4.0 < 2"
-
-http-errors@~1.7.2:
+http-errors@1.7.3, http-errors@~1.7.2:
version "1.7.3"
resolved "https://registry.npm.taobao.org/http-errors/download/http-errors-1.7.3.tgz?cache=0&sync_timestamp=1593407858306&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhttp-errors%2Fdownload%2Fhttp-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06"
integrity sha1-bGGeT5xgMIw4UZSYwU+7EKrOuwY=
@@ -5297,11 +5434,30 @@ http-errors@~1.7.2:
statuses ">= 1.5.0 < 2"
toidentifier "1.0.0"
+http-errors@~1.6.2:
+ version "1.6.3"
+ resolved "https://registry.npm.taobao.org/http-errors/download/http-errors-1.6.3.tgz?cache=0&sync_timestamp=1593407858306&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhttp-errors%2Fdownload%2Fhttp-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d"
+ integrity sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=
+ dependencies:
+ depd "~1.1.2"
+ inherits "2.0.3"
+ setprototypeof "1.1.0"
+ statuses ">= 1.4.0 < 2"
+
http-parser-js@>=0.5.1:
version "0.5.2"
resolved "https://registry.npm.taobao.org/http-parser-js/download/http-parser-js-0.5.2.tgz#da2e31d237b393aae72ace43882dd7e270a8ff77"
integrity sha1-2i4x0jezk6rnKs5DiC3X4nCo/3c=
+http-proxy-agent@^4.0.1:
+ version "4.0.1"
+ resolved "https://registry.npm.taobao.org/http-proxy-agent/download/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a"
+ integrity sha1-ioyO9/WTLM+VPClsqCkblap0qjo=
+ dependencies:
+ "@tootallnate/once" "1"
+ agent-base "6"
+ debug "4"
+
http-proxy-middleware@0.19.1:
version "0.19.1"
resolved "https://registry.npm.taobao.org/http-proxy-middleware/download/http-proxy-middleware-0.19.1.tgz#183c7dc4aa1479150306498c210cdaf96080a43a"
@@ -5335,6 +5491,14 @@ https-browserify@^1.0.0:
resolved "https://registry.npm.taobao.org/https-browserify/download/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
+https-proxy-agent@5:
+ version "5.0.0"
+ resolved "https://registry.npm.taobao.org/https-proxy-agent/download/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
+ integrity sha1-4qkFQqu2inYuCghQ9sntrf2FBrI=
+ dependencies:
+ agent-base "6"
+ debug "4"
+
human-signals@^1.1.1:
version "1.1.1"
resolved "https://registry.npm.taobao.org/human-signals/download/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
@@ -5868,6 +6032,11 @@ is-yarn-global@^0.3.0:
resolved "https://registry.npm.taobao.org/is-yarn-global/download/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232"
integrity sha1-1QLTOCWQ6jAEiTdGdUyJE5lz4jI=
+isarray@0.0.1:
+ version "0.0.1"
+ resolved "https://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
+ integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=
+
isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -6569,6 +6738,11 @@ mime-db@1.44.0, "mime-db@>= 1.43.0 < 2":
resolved "https://registry.npm.taobao.org/mime-db/download/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92"
integrity sha1-+hHF6wrKEzS0Izy01S8QxaYnL5I=
+mime-db@^1.28.0:
+ version "1.45.0"
+ resolved "https://registry.npm.taobao.org/mime-db/download/mime-db-1.45.0.tgz?cache=0&sync_timestamp=1600831210195&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmime-db%2Fdownload%2Fmime-db-1.45.0.tgz#cceeda21ccd7c3a745eba2decd55d4b73e7879ea"
+ integrity sha1-zO7aIczXw6dF66LezVXUtz54eeo=
+
mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24:
version "2.1.27"
resolved "https://registry.npm.taobao.org/mime-types/download/mime-types-2.1.27.tgz?cache=0&sync_timestamp=1589682770020&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmime-types%2Fdownload%2Fmime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f"
@@ -6710,6 +6884,11 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.npm.taobao.org/mkdirp/download/mkdirp-1.0.4.tgz?cache=0&sync_timestamp=1589682820707&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmkdirp%2Fdownload%2Fmkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha1-PrXtYmInVteaXw4qIh3+utdcL34=
+modify-filename@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.npm.taobao.org/modify-filename/download/modify-filename-1.1.0.tgz#9a2dec83806fbb2d975f22beec859ca26b393aa1"
+ integrity sha1-mi3sg4Bvuy2XXyK+7IWcoms5OqE=
+
move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.npm.taobao.org/move-concurrently/download/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
@@ -6801,6 +6980,11 @@ neo-async@^2.5.0, neo-async@^2.6.0, neo-async@^2.6.1, neo-async@^2.6.2:
resolved "https://registry.npm.taobao.org/neo-async/download/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha1-tKr7k+OustgXTKU88WOrfXMIMF8=
+netmask@^1.0.6:
+ version "1.0.6"
+ resolved "https://registry.npm.taobao.org/netmask/download/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35"
+ integrity sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=
+
nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.npm.taobao.org/nice-try/download/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
@@ -7098,7 +7282,7 @@ opn@^5.5.0:
dependencies:
is-wsl "^1.1.0"
-optionator@^0.8.3:
+optionator@^0.8.1, optionator@^0.8.3:
version "0.8.3"
resolved "https://registry.npm.taobao.org/optionator/download/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
integrity sha1-hPodA2/p08fiHZmIS2ARZ+yPtJU=
@@ -7232,6 +7416,30 @@ p-try@^2.0.0:
resolved "https://registry.npm.taobao.org/p-try/download/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha1-yyhoVA4xPWHeWPr741zpAE1VQOY=
+pac-proxy-agent@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.npm.taobao.org/pac-proxy-agent/download/pac-proxy-agent-4.1.0.tgz#66883eeabadc915fc5e95457324cb0f0ac78defb"
+ integrity sha1-Zog+6rrckV/F6VRXMkyw8Kx43vs=
+ dependencies:
+ "@tootallnate/once" "1"
+ agent-base "6"
+ debug "4"
+ get-uri "3"
+ http-proxy-agent "^4.0.1"
+ https-proxy-agent "5"
+ pac-resolver "^4.1.0"
+ raw-body "^2.2.0"
+ socks-proxy-agent "5"
+
+pac-resolver@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.npm.taobao.org/pac-resolver/download/pac-resolver-4.1.0.tgz#4b12e7d096b255a3b84e53f6831f32e9c7e5fe95"
+ integrity sha1-SxLn0JayVaO4TlP2gx8y6cfl/pU=
+ dependencies:
+ degenerator "^2.2.0"
+ ip "^1.1.5"
+ netmask "^1.0.6"
+
package-json@^6.3.0:
version "6.5.0"
resolved "https://registry.npm.taobao.org/package-json/download/package-json-6.5.0.tgz?cache=0&sync_timestamp=1589683698535&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fpackage-json%2Fdownload%2Fpackage-json-6.5.0.tgz#6feedaca35e75725876d0b0e64974697fed145b0"
@@ -8128,6 +8336,16 @@ raw-body@2.4.0:
iconv-lite "0.4.24"
unpipe "1.0.0"
+raw-body@^2.2.0:
+ version "2.4.1"
+ resolved "https://registry.npm.taobao.org/raw-body/download/raw-body-2.4.1.tgz#30ac82f98bb5ae8c152e67149dac8d55153b168c"
+ integrity sha1-MKyC+Yu1rowVLmcUnayNVRU7Fow=
+ dependencies:
+ bytes "3.1.0"
+ http-errors "1.7.3"
+ iconv-lite "0.4.24"
+ unpipe "1.0.0"
+
rc@^1.2.8:
version "1.2.8"
resolved "https://registry.npm.taobao.org/rc/download/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
@@ -8172,6 +8390,16 @@ read-pkg@^5.1.1:
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
+readable-stream@1.1.x:
+ version "1.1.14"
+ resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.1.14.tgz?cache=0&sync_timestamp=1589682741447&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freadable-stream%2Fdownload%2Freadable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9"
+ integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk=
+ dependencies:
+ core-util-is "~1.0.0"
+ inherits "~2.0.1"
+ isarray "0.0.1"
+ string_decoder "~0.10.x"
+
readable-stream@^3.0.0, readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.6.0:
version "3.6.0"
resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.6.0.tgz?cache=0&sync_timestamp=1589682741447&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freadable-stream%2Fdownload%2Freadable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
@@ -8789,6 +9017,20 @@ slice-ansi@^2.1.0:
astral-regex "^1.0.0"
is-fullwidth-code-point "^2.0.0"
+slice-ansi@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.npm.taobao.org/slice-ansi/download/slice-ansi-3.0.0.tgz#31ddc10930a1b7e0b67b08c96c2f49b77a789787"
+ integrity sha1-Md3BCTCht+C2ewjJbC9Jt3p4l4c=
+ dependencies:
+ ansi-styles "^4.0.0"
+ astral-regex "^2.0.0"
+ is-fullwidth-code-point "^3.0.0"
+
+smart-buffer@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.npm.taobao.org/smart-buffer/download/smart-buffer-4.1.0.tgz#91605c25d91652f4661ea69ccf45f1b331ca21ba"
+ integrity sha1-kWBcJdkWUvRmHqacz0XxszHKIbo=
+
snapdragon-node@^2.0.1:
version "2.1.1"
resolved "https://registry.npm.taobao.org/snapdragon-node/download/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
@@ -8840,6 +9082,30 @@ sockjs@0.3.20:
uuid "^3.4.0"
websocket-driver "0.6.5"
+socks-proxy-agent@5:
+ version "5.0.0"
+ resolved "https://registry.npm.taobao.org/socks-proxy-agent/download/socks-proxy-agent-5.0.0.tgz#7c0f364e7b1cf4a7a437e71253bed72e9004be60"
+ integrity sha1-fA82Tnsc9KekN+cSU77XLpAEvmA=
+ dependencies:
+ agent-base "6"
+ debug "4"
+ socks "^2.3.3"
+
+socks@^2.3.3:
+ version "2.5.0"
+ resolved "https://registry.npm.taobao.org/socks/download/socks-2.5.0.tgz?cache=0&sync_timestamp=1603686517008&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsocks%2Fdownload%2Fsocks-2.5.0.tgz#3a7c286db114f67864a4bd8b4207a91d1db3d6db"
+ integrity sha1-OnwobbEU9nhkpL2LQgepHR2z1ts=
+ dependencies:
+ ip "^1.1.5"
+ smart-buffer "^4.1.0"
+
+sort-keys-length@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.npm.taobao.org/sort-keys-length/download/sort-keys-length-1.0.1.tgz#9cb6f4f4e9e48155a6aa0671edd336ff1479a188"
+ integrity sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg=
+ dependencies:
+ sort-keys "^1.0.0"
+
sort-keys@^1.0.0:
version "1.1.2"
resolved "https://registry.npm.taobao.org/sort-keys/download/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad"
@@ -9061,6 +9327,11 @@ stream-shift@^1.0.0:
resolved "https://registry.npm.taobao.org/stream-shift/download/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d"
integrity sha1-1wiCgVWasneEJCebCHfaPDktWj0=
+streamsearch@0.1.2:
+ version "0.1.2"
+ resolved "https://registry.npm.taobao.org/streamsearch/download/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a"
+ integrity sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=
+
strict-uri-encode@^1.0.0:
version "1.1.0"
resolved "https://registry.npm.taobao.org/strict-uri-encode/download/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
@@ -9115,6 +9386,11 @@ string_decoder@^1.0.0, string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"
+string_decoder@~0.10.x:
+ version "0.10.31"
+ resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
+ integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=
+
string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
@@ -9580,6 +9856,11 @@ tslib@^1.9.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
+tslib@^2.0.1:
+ version "2.0.3"
+ resolved "https://registry.npm.taobao.org/tslib/download/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c"
+ integrity sha1-jgdBrEX8DCJuWKF7/D5kubxsphw=
+
tty-browserify@0.0.0:
version "0.0.0"
resolved "https://registry.npm.taobao.org/tty-browserify/download/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
@@ -9754,6 +10035,14 @@ unset-value@^1.0.0:
has-value "^0.3.1"
isobject "^3.0.0"
+unused-filename@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.npm.taobao.org/unused-filename/download/unused-filename-2.1.0.tgz#33719c4e8d9644f32d2dec1bc8525c6aaeb4ba51"
+ integrity sha1-M3GcTo2WRPMtLewbyFJcaq60ulE=
+ dependencies:
+ modify-filename "^1.1.0"
+ path-exists "^4.0.0"
+
unzip-crx-3@^0.2.0:
version "0.2.0"
resolved "https://registry.npm.taobao.org/unzip-crx-3/download/unzip-crx-3-0.2.0.tgz#d5324147b104a8aed9ae8639c95521f6f7cda292"
@@ -10535,6 +10824,11 @@ xdg-basedir@^4.0.0:
resolved "https://registry.npm.taobao.org/xdg-basedir/download/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
integrity sha1-S8jZmEQDaWIl74OhVzy7y0552xM=
+xregexp@2.0.0:
+ version "2.0.0"
+ resolved "https://registry.npm.taobao.org/xregexp/download/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943"
+ integrity sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=
+
xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.npm.taobao.org/xtend/download/xtend-4.0.2.tgz?cache=0&sync_timestamp=1589682817913&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxtend%2Fdownload%2Fxtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"