mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-05 15:08:56 +08:00
commit
c2d738822e
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
|
@ -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) {
|
||||
|
5524
package-lock.json
generated
5524
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,8 @@
|
||||
"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": [
|
||||
"网易云音乐",
|
||||
@ -53,6 +54,7 @@
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"eslint-plugin-html": "6.1.2",
|
||||
"eslint-plugin-prettier": "3.3.1",
|
||||
"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