mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-03 07:52:09 +08:00
Merge branch 'Binaryify:master' into master
This commit is contained in:
commit
055775bf75
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_
|
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx lint-staged
|
@ -1,4 +1,6 @@
|
||||
# 更新日志
|
||||
### 4.0.13 | 2021.5.24
|
||||
- 修复解析问题,改善 Docker 支持 [#1241](https://github.com/Binaryify/NeteaseCloudMusicApi/pull/1241)
|
||||
### 4.0.12 | 2021.5.1
|
||||
- 首页-发现接口增加 cursor 参数,refresh默认设为false [#1217](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1217)
|
||||
|
||||
|
@ -3,11 +3,8 @@ FROM node:lts-alpine
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
RUN rm -f package-lock.json \
|
||||
; rm -rf .idea \
|
||||
; rm -rf node_modules \
|
||||
; npm config set registry "https://registry.npm.taobao.org/" \
|
||||
&& npm install
|
||||
RUN npm config set registry "https://registry.npm.taobao.org/" \
|
||||
&& npm install --production
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["node", "app.js"]
|
||||
|
5
app.js
5
app.js
@ -42,9 +42,8 @@ app.use((req, res, next) => {
|
||||
;(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()
|
||||
req.cookies[decodeURIComponent(pair.slice(0, crack)).trim()] =
|
||||
decodeURIComponent(pair.slice(crack + 1)).trim()
|
||||
})
|
||||
next()
|
||||
})
|
||||
|
@ -13,7 +13,8 @@ module.exports = (query, request) => {
|
||||
},
|
||||
).then((response) => {
|
||||
try {
|
||||
const pattern = /<div class="cver u-cover u-cover-3">[\s\S]*?<img src="([^"]+)">[\s\S]*?<a class="sname f-fs1 s-fc0" href="([^"]+)"[^>]*>([^<]+?)<\/a>[\s\S]*?<a class="nm nm f-thide s-fc3" href="([^"]+)"[^>]*>([^<]+?)<\/a>/g
|
||||
const pattern =
|
||||
/<div class="cver u-cover u-cover-3">[\s\S]*?<img src="([^"]+)">[\s\S]*?<a class="sname f-fs1 s-fc0" href="([^"]+)"[^>]*>([^<]+?)<\/a>[\s\S]*?<a class="nm nm f-thide s-fc3" href="([^"]+)"[^>]*>([^<]+?)<\/a>/g
|
||||
let result,
|
||||
playlists = []
|
||||
while ((result = pattern.exec(response.body)) != null) {
|
||||
|
5539
package-lock.json
generated
5539
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "4.0.12",
|
||||
"version": "4.0.13",
|
||||
"description": "网易云音乐 NodeJS 版 API",
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
"test": "mocha -r intelli-espower-loader -t 20000 app.test.js --exit",
|
||||
"lint": "eslint **/*.{js,ts}",
|
||||
"lint-fix": "eslint --fix **/*.{js,ts}"
|
||||
"lint-fix": "eslint --fix **/*.{js,ts}",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"keywords": [
|
||||
"网易云音乐",
|
||||
@ -52,7 +53,8 @@
|
||||
"eslint": "7.23.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"eslint-plugin-html": "6.1.2",
|
||||
"eslint-plugin-prettier": "3.3.1",
|
||||
"eslint-plugin-prettier": "3.4.0",
|
||||
"husky": "6.0.0",
|
||||
"intelli-espower-loader": "1.0.1",
|
||||
"lint-staged": "11.0.0",
|
||||
"mocha": "8.3.2",
|
||||
|
@ -127,7 +127,7 @@ const createRequest = (method, url, data, options) => {
|
||||
settings.httpAgent = new PacProxyAgent(options.proxy)
|
||||
settings.httpsAgent = new PacProxyAgent(options.proxy)
|
||||
} else {
|
||||
var purl = qs.parse(options.proxy)
|
||||
const purl = qs.parse(options.proxy)
|
||||
if (purl.hostname) {
|
||||
const agent = tunnel.httpsOverHttp({
|
||||
proxy: {
|
||||
@ -172,13 +172,19 @@ const createRequest = (method, url, data, options) => {
|
||||
}
|
||||
} catch (e) {
|
||||
// console.log(e)
|
||||
try {
|
||||
answer.body = JSON.parse(body.toString())
|
||||
} catch (err) {
|
||||
// console.log(err)
|
||||
// can't decrypt and can't parse directly
|
||||
answer.body = body
|
||||
}
|
||||
answer.status = res.status
|
||||
}
|
||||
|
||||
answer.status =
|
||||
100 < answer.status && answer.status < 600 ? answer.status : 400
|
||||
if (answer.status == 200) resolve(answer)
|
||||
if (answer.status === 200) resolve(answer)
|
||||
else reject(answer)
|
||||
})
|
||||
.catch((err) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user