@sansenjian/qq-music-api 1.0.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +2 -2
- package/.dockerignore +5 -5
- package/.editorconfig +31 -31
- package/.eslintrc.json +21 -17
- package/.github/FUNDING.yml +12 -12
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
- package/.github/ISSUE_TEMPLATE/custom.md +24 -24
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
- package/.github/workflows/publish.yml +26 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +1 -1
- package/.prettierrc +9 -9
- package/CHANGELOG.md +70 -70
- package/Dockerfile +18 -18
- package/LICENSE +21 -21
- package/README.md +218 -177
- package/app.js +75 -75
- package/commitlint.config.js +20 -20
- package/config/user-info.js +42 -42
- package/index.js +1 -1
- package/middlewares/koa-cors.js +97 -97
- package/module/apis/UCommon/UCommon.js +6 -6
- package/module/apis/album/getAlbumInfo.js +33 -33
- package/module/apis/comments/getComments.js +35 -35
- package/module/apis/digitalAlbum/getDigitalAlbumLists.js +34 -34
- package/module/apis/downloadQQMusic.js +41 -41
- package/module/apis/music/getLyric.js +42 -41
- package/module/apis/mv/getMvByTag.js +35 -35
- package/module/apis/radio/getRadioLists.js +38 -38
- package/module/apis/rank/getTopLists.js +44 -44
- package/module/apis/search/getHotKey.js +35 -35
- package/module/apis/search/getSearchByKey.js +45 -45
- package/module/apis/search/getSmartbox.js +34 -34
- package/module/apis/singers/getSimilarSinger.js +36 -36
- package/module/apis/singers/getSingerDesc.js +38 -38
- package/module/apis/singers/getSingerMv.js +35 -35
- package/module/apis/singers/getSingerStarNum.js +36 -36
- package/module/apis/songLists/songListCategories.js +33 -33
- package/module/apis/songLists/songListDetail.js +38 -38
- package/module/apis/songLists/songLists.js +41 -41
- package/module/apis/u_common.js +17 -16
- package/module/apis/user/checkQQLoginQr.js +125 -86
- package/module/apis/user/getQQLoginQr.js +17 -11
- package/module/apis/y_common.js +27 -14
- package/module/config.js +31 -31
- package/module/index.js +82 -82
- package/package.json +72 -83
- package/public/index.html +47 -47
- package/routers/context/batchGetSongInfo.js +59 -59
- package/routers/context/batchGetSongLists.js +50 -50
- package/routers/context/checkQQLoginQr.js +17 -15
- package/routers/context/cookies.js +36 -36
- package/routers/context/getAlbumInfo.js +27 -27
- package/routers/context/getComments.js +51 -51
- package/routers/context/getDigitalAlbumLists.js +14 -14
- package/routers/context/getDownloadQQMusic.js +14 -14
- package/routers/context/getHotkey.js +14 -14
- package/routers/context/getImageUrl.js +34 -34
- package/routers/context/getLyric.js +26 -26
- package/routers/context/getMusicPlay.js +116 -112
- package/routers/context/getMv.js +56 -56
- package/routers/context/getMvByTag.js +15 -15
- package/routers/context/getMvPlay.js +128 -118
- package/routers/context/getNewDisks.js +50 -51
- package/routers/context/getQQLoginQr.js +12 -12
- package/routers/context/getRadioLists.js +14 -14
- package/routers/context/getRanks.js +90 -86
- package/routers/context/getRecommend.js +86 -86
- package/routers/context/getSearchByKey.js +32 -32
- package/routers/context/getSimilarSinger.js +25 -25
- package/routers/context/getSingerAlbum.js +52 -52
- package/routers/context/getSingerDesc.js +25 -25
- package/routers/context/getSingerHotsong.js +52 -52
- package/routers/context/getSingerList.js +51 -52
- package/routers/context/getSingerMv.js +32 -32
- package/routers/context/getSingerStarNum.js +24 -24
- package/routers/context/getSmartbox.js +24 -24
- package/routers/context/getSongInfo.js +49 -49
- package/routers/context/getSongListCategories.js +22 -22
- package/routers/context/getSongListDetail.js +25 -25
- package/routers/context/getSongLists.js +32 -32
- package/routers/context/getTicketInfo.js +45 -45
- package/routers/context/getTopLists.js +15 -15
- package/routers/context/index.js +74 -74
- package/routers/router.js +116 -112
- package/scripts/build-images.js +36 -36
- package/scripts/commit-push.sh +103 -103
- package/util/colors.js +16 -16
- package/util/cookie.js +22 -22
- package/util/loginUtils.js +28 -23
- package/util/lyricParse.js +64 -64
- package/util/request.js +57 -57
- package/vercel.json +15 -15
package/scripts/build-images.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const {exec} = require('child_process');
|
|
2
|
-
const { version, author } = require('../package.json');
|
|
3
|
-
|
|
4
|
-
const isLocal = process.argv[2] === 'local';
|
|
5
|
-
|
|
6
|
-
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Build Images Start ------------\n`);
|
|
7
|
-
|
|
8
|
-
// const run = 'docker run -d --name qq-music-api -p 3200:3200 qq-music-api'
|
|
9
|
-
const image = `${isLocal ? '' : `${author.toLowerCase()}/`}qq-music-api:${version}`
|
|
10
|
-
const cmd = isLocal
|
|
11
|
-
? `docker build -t ${image} .`
|
|
12
|
-
: `docker image tag qq-music-api:${version} ${image}`;
|
|
13
|
-
|
|
14
|
-
console.log('cmd:', cmd, '\n');
|
|
15
|
-
|
|
16
|
-
exec(cmd, {}, (err, stdout, stderr) => {
|
|
17
|
-
if (err) {
|
|
18
|
-
console.log(err);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
console.log(stdout, stderr);
|
|
22
|
-
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Build Images End ------------\n`);
|
|
23
|
-
if (!isLocal) {
|
|
24
|
-
const pushCmd = `docker image push ${image}`;
|
|
25
|
-
console.log('pushCmd:', pushCmd, '\n');
|
|
26
|
-
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Push Images Start ------------\n`);
|
|
27
|
-
exec(pushCmd, {}, (err, stdout, stderr) => {
|
|
28
|
-
if (err) {
|
|
29
|
-
console.log(err);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
console.log(stdout, stderr);
|
|
33
|
-
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Push Images End ------------\n`);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
1
|
+
const {exec} = require('child_process');
|
|
2
|
+
const { version, author } = require('../package.json');
|
|
3
|
+
|
|
4
|
+
const isLocal = process.argv[2] === 'local';
|
|
5
|
+
|
|
6
|
+
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Build Images Start ------------\n`);
|
|
7
|
+
|
|
8
|
+
// const run = 'docker run -d --name qq-music-api -p 3200:3200 qq-music-api'
|
|
9
|
+
const image = `${isLocal ? '' : `${author.toLowerCase()}/`}qq-music-api:${version}`
|
|
10
|
+
const cmd = isLocal
|
|
11
|
+
? `docker build -t ${image} .`
|
|
12
|
+
: `docker image tag qq-music-api:${version} ${image}`;
|
|
13
|
+
|
|
14
|
+
console.log('cmd:', cmd, '\n');
|
|
15
|
+
|
|
16
|
+
exec(cmd, {}, (err, stdout, stderr) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
console.log(err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(stdout, stderr);
|
|
22
|
+
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Build Images End ------------\n`);
|
|
23
|
+
if (!isLocal) {
|
|
24
|
+
const pushCmd = `docker image push ${image}`;
|
|
25
|
+
console.log('pushCmd:', pushCmd, '\n');
|
|
26
|
+
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Push Images Start ------------\n`);
|
|
27
|
+
exec(pushCmd, {}, (err, stdout, stderr) => {
|
|
28
|
+
if (err) {
|
|
29
|
+
console.log(err);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
console.log(stdout, stderr);
|
|
33
|
+
console.log(`------------ ${isLocal ? 'Local' : 'Remote'} Docker Push Images End ------------\n`);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
package/scripts/commit-push.sh
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
###
|
|
2
|
-
# @Author: Rainy
|
|
3
|
-
# @Date: 2020-05-24 13:05:40
|
|
4
|
-
# @LastEditors: Rainy
|
|
5
|
-
# @LastEditTime: 2020-05-24 13:06:02
|
|
6
|
-
###
|
|
7
|
-
|
|
8
|
-
#!/usr/bin/env bash
|
|
9
|
-
|
|
10
|
-
echo "------------ commit push shell run ------------"
|
|
11
|
-
|
|
12
|
-
read -p "Input your commit msg (*): " msg
|
|
13
|
-
read -p "Amend commit(Y, y, default: N): " amend
|
|
14
|
-
read -p "Need pull current branch(Y, y, default: N): " pull
|
|
15
|
-
|
|
16
|
-
len=120
|
|
17
|
-
curBranch=$(git branch | awk '/\*/ { print $2; }')
|
|
18
|
-
|
|
19
|
-
# start reg
|
|
20
|
-
msgRegLower='^\s*(feat|fix|docs|style|chore|build|ci|perf|refactor|revert|test|temp|update)\s*\:*\s*'
|
|
21
|
-
msgRegUpper='^\s*(Feat|Fix|Docs|Style|Chore|Build|Ci|Perf|Refactor|Revert|Test|Temp|Update)\s*\:*\s*'
|
|
22
|
-
|
|
23
|
-
# 另一种获取当前 branch_name 的方法
|
|
24
|
-
# git symbolic-ref --short HEAD
|
|
25
|
-
|
|
26
|
-
echo "Log: Cureren branch is ${curBranch}"
|
|
27
|
-
|
|
28
|
-
if [[ $pull = "Y" || $pull = "y" ]];then
|
|
29
|
-
|
|
30
|
-
read -p "Need pull branch(default: current branch, eg: master): " branch
|
|
31
|
-
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
if [ -n "$msg" ];then
|
|
35
|
-
|
|
36
|
-
echo "Log: Commit msg: $msg"
|
|
37
|
-
|
|
38
|
-
if [ ${#msg} -gt $len ];then
|
|
39
|
-
echo "Error: msg length must less than $len"
|
|
40
|
-
exit 1
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
if [[ "$msg" =~ $msgRegLower || "$msg" =~ $msgRegUpper ]];then
|
|
44
|
-
|
|
45
|
-
git add .
|
|
46
|
-
|
|
47
|
-
if [[ $amend = "Y" || $amend = "y" ]];then
|
|
48
|
-
echo "Log: Amending message commit"
|
|
49
|
-
git commit --amend -m "$msg" || exit 1
|
|
50
|
-
else
|
|
51
|
-
echo "Log: Commiting"
|
|
52
|
-
git commit -m "$msg" || exit 1
|
|
53
|
-
fi
|
|
54
|
-
|
|
55
|
-
if [[ $pull = "Y" || $pull = "y" ]];then
|
|
56
|
-
|
|
57
|
-
if [ -n "$branch" ];then
|
|
58
|
-
|
|
59
|
-
echo "Log: Pulling branch is $branch"
|
|
60
|
-
|
|
61
|
-
fi
|
|
62
|
-
|
|
63
|
-
branch=${curBranch}
|
|
64
|
-
|
|
65
|
-
echo "Log: Pulling ${branch} from remote"
|
|
66
|
-
git pull origin ${branch} || exit 1
|
|
67
|
-
|
|
68
|
-
else
|
|
69
|
-
|
|
70
|
-
branch=${curBranch}
|
|
71
|
-
|
|
72
|
-
echo "Log: Current branch is $branch"
|
|
73
|
-
|
|
74
|
-
echo "Log: Jump pull branch"
|
|
75
|
-
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
read -p "Auto Push(Y, y, default: Y): " push
|
|
79
|
-
|
|
80
|
-
if [ -z "${push}" ];then
|
|
81
|
-
push='Y'
|
|
82
|
-
fi
|
|
83
|
-
|
|
84
|
-
if [[ $push = "Y" || $push = "y" ]];then
|
|
85
|
-
|
|
86
|
-
echo "Log: Pushing"
|
|
87
|
-
|
|
88
|
-
git push origin ${branch} || exit 1
|
|
89
|
-
fi
|
|
90
|
-
|
|
91
|
-
echo "------------ commit push shell end ------------"
|
|
92
|
-
|
|
93
|
-
else
|
|
94
|
-
echo "Error: Commit message start type must be one of [feat, fix, docs, style, chore, build, ci, perf, refactor, revert, test, temp, Feat, Fix, Docs, Style, Chore, Build, Ci, Perf, Refactor, Revert, Test, Temp]"
|
|
95
|
-
exit 1
|
|
96
|
-
fi
|
|
97
|
-
|
|
98
|
-
else
|
|
99
|
-
|
|
100
|
-
echo "Please input commit msg"
|
|
101
|
-
exit 1
|
|
102
|
-
|
|
103
|
-
fi
|
|
1
|
+
###
|
|
2
|
+
# @Author: Rainy
|
|
3
|
+
# @Date: 2020-05-24 13:05:40
|
|
4
|
+
# @LastEditors: Rainy
|
|
5
|
+
# @LastEditTime: 2020-05-24 13:06:02
|
|
6
|
+
###
|
|
7
|
+
|
|
8
|
+
#!/usr/bin/env bash
|
|
9
|
+
|
|
10
|
+
echo "------------ commit push shell run ------------"
|
|
11
|
+
|
|
12
|
+
read -p "Input your commit msg (*): " msg
|
|
13
|
+
read -p "Amend commit(Y, y, default: N): " amend
|
|
14
|
+
read -p "Need pull current branch(Y, y, default: N): " pull
|
|
15
|
+
|
|
16
|
+
len=120
|
|
17
|
+
curBranch=$(git branch | awk '/\*/ { print $2; }')
|
|
18
|
+
|
|
19
|
+
# start reg
|
|
20
|
+
msgRegLower='^\s*(feat|fix|docs|style|chore|build|ci|perf|refactor|revert|test|temp|update)\s*\:*\s*'
|
|
21
|
+
msgRegUpper='^\s*(Feat|Fix|Docs|Style|Chore|Build|Ci|Perf|Refactor|Revert|Test|Temp|Update)\s*\:*\s*'
|
|
22
|
+
|
|
23
|
+
# 另一种获取当前 branch_name 的方法
|
|
24
|
+
# git symbolic-ref --short HEAD
|
|
25
|
+
|
|
26
|
+
echo "Log: Cureren branch is ${curBranch}"
|
|
27
|
+
|
|
28
|
+
if [[ $pull = "Y" || $pull = "y" ]];then
|
|
29
|
+
|
|
30
|
+
read -p "Need pull branch(default: current branch, eg: master): " branch
|
|
31
|
+
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
if [ -n "$msg" ];then
|
|
35
|
+
|
|
36
|
+
echo "Log: Commit msg: $msg"
|
|
37
|
+
|
|
38
|
+
if [ ${#msg} -gt $len ];then
|
|
39
|
+
echo "Error: msg length must less than $len"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
if [[ "$msg" =~ $msgRegLower || "$msg" =~ $msgRegUpper ]];then
|
|
44
|
+
|
|
45
|
+
git add .
|
|
46
|
+
|
|
47
|
+
if [[ $amend = "Y" || $amend = "y" ]];then
|
|
48
|
+
echo "Log: Amending message commit"
|
|
49
|
+
git commit --amend -m "$msg" || exit 1
|
|
50
|
+
else
|
|
51
|
+
echo "Log: Commiting"
|
|
52
|
+
git commit -m "$msg" || exit 1
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
if [[ $pull = "Y" || $pull = "y" ]];then
|
|
56
|
+
|
|
57
|
+
if [ -n "$branch" ];then
|
|
58
|
+
|
|
59
|
+
echo "Log: Pulling branch is $branch"
|
|
60
|
+
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
branch=${curBranch}
|
|
64
|
+
|
|
65
|
+
echo "Log: Pulling ${branch} from remote"
|
|
66
|
+
git pull origin ${branch} || exit 1
|
|
67
|
+
|
|
68
|
+
else
|
|
69
|
+
|
|
70
|
+
branch=${curBranch}
|
|
71
|
+
|
|
72
|
+
echo "Log: Current branch is $branch"
|
|
73
|
+
|
|
74
|
+
echo "Log: Jump pull branch"
|
|
75
|
+
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
read -p "Auto Push(Y, y, default: Y): " push
|
|
79
|
+
|
|
80
|
+
if [ -z "${push}" ];then
|
|
81
|
+
push='Y'
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
if [[ $push = "Y" || $push = "y" ]];then
|
|
85
|
+
|
|
86
|
+
echo "Log: Pushing"
|
|
87
|
+
|
|
88
|
+
git push origin ${branch} || exit 1
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
echo "------------ commit push shell end ------------"
|
|
92
|
+
|
|
93
|
+
else
|
|
94
|
+
echo "Error: Commit message start type must be one of [feat, fix, docs, style, chore, build, ci, perf, refactor, revert, test, temp, Feat, Fix, Docs, Style, Chore, Build, Ci, Perf, Refactor, Revert, Test, Temp]"
|
|
95
|
+
exit 1
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
else
|
|
99
|
+
|
|
100
|
+
echo "Please input commit msg"
|
|
101
|
+
exit 1
|
|
102
|
+
|
|
103
|
+
fi
|
package/util/colors.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
colors
|
|
4
|
-
silly: '
|
|
5
|
-
input:
|
|
6
|
-
verbose:
|
|
7
|
-
prompt:
|
|
8
|
-
info:
|
|
9
|
-
data:
|
|
10
|
-
help:
|
|
11
|
-
warn:
|
|
12
|
-
debug:
|
|
13
|
-
error:
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = colors;
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
const colors = {
|
|
4
|
+
silly: text => chalk.hex('#ff69b4')(text),
|
|
5
|
+
input: text => chalk.grey(text),
|
|
6
|
+
verbose: text => chalk.cyan(text),
|
|
7
|
+
prompt: text => chalk.white(text),
|
|
8
|
+
info: text => chalk.green(text),
|
|
9
|
+
data: text => chalk.grey(text),
|
|
10
|
+
help: text => chalk.cyan(text),
|
|
11
|
+
warn: text => chalk.yellow(text),
|
|
12
|
+
debug: text => chalk.blue(text),
|
|
13
|
+
error: text => chalk.red(text),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = colors;
|
package/util/cookie.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
module.exports = () => async (ctx, next) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
1
|
+
module.exports = () => async (ctx, next) => {
|
|
2
|
+
if (global.userInfo?.cookie) {
|
|
3
|
+
ctx.request.cookie = global.userInfo.cookie;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const cookieHeader = ctx.request.headers;
|
|
7
|
+
|
|
8
|
+
if (cookieHeader && Array.isArray(global.userInfo?.cookieList)) {
|
|
9
|
+
global.userInfo.cookieList.forEach(cookie => {
|
|
10
|
+
const [key, value = ''] = cookie.split('=');
|
|
11
|
+
|
|
12
|
+
if (value) {
|
|
13
|
+
ctx.cookies.set(key, value.trim(), {
|
|
14
|
+
// maxAge: 24 * 60 * 60 * 1000,
|
|
15
|
+
overwrite: true,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
await next();
|
|
22
|
+
};
|
package/util/loginUtils.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
const hash33 =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
const hash33 = t => {
|
|
2
|
+
let e = 0;
|
|
3
|
+
for (let n = 0, o = t.length; n < o; ++n) {
|
|
4
|
+
e += (e << 5) + t.charCodeAt(n);
|
|
5
|
+
}
|
|
6
|
+
return 2147483647 & e;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getGtk = p_skey => {
|
|
10
|
+
const str = p_skey;
|
|
11
|
+
let hash = 5381;
|
|
12
|
+
for (let i = 0, len = str.length; i < len; ++i) {
|
|
13
|
+
hash += (hash << 5) + str.charCodeAt(i);
|
|
14
|
+
}
|
|
15
|
+
return hash & 0x7fffffff;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getGuid = () => {
|
|
19
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
|
20
|
+
.replace(/[xy]/g, function (c) {
|
|
21
|
+
const r = (Math.random() * 16) | 0;
|
|
22
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
23
|
+
return v.toString(16);
|
|
24
|
+
})
|
|
25
|
+
.toUpperCase();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = { hash33, getGtk, getGuid };
|
package/util/lyricParse.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
// [01:27.96]
|
|
2
|
-
const timeExp = /\[(\d{2,}):(\d{2})(?:\.(\d{2,3}))?]/g;
|
|
3
|
-
|
|
4
|
-
const TAGREGMAP = {
|
|
5
|
-
title: 'ti',
|
|
6
|
-
artist: 'ar',
|
|
7
|
-
album: 'al',
|
|
8
|
-
offset: 'offset',
|
|
9
|
-
by: 'by',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
class Lyric {
|
|
13
|
-
constructor(lyric) {
|
|
14
|
-
this.lyric = lyric;
|
|
15
|
-
this.tags = {};
|
|
16
|
-
this.lines = [];
|
|
17
|
-
|
|
18
|
-
this._init();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_init() {
|
|
22
|
-
this._initTag();
|
|
23
|
-
|
|
24
|
-
this._initLines();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
_initTag() {
|
|
28
|
-
for (
|
|
29
|
-
const matches = this.lyric.match(new RegExp(`\\[${TAGREGMAP[tag]}:([^\\]]*)]`, 'i'));
|
|
30
|
-
this.tags[tag] = (matches && matches[1]) || '';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_initLines() {
|
|
35
|
-
const lines = this.lyric.split('\n');
|
|
36
|
-
for (let i = 0; i < lines.length; i++) {
|
|
37
|
-
const line = lines[i];
|
|
38
|
-
|
|
39
|
-
if (result) {
|
|
40
|
-
const txt = line.replace(timeExp, '').trim();
|
|
41
|
-
const time = result[1] * 60 * 1000 + result[2] * 1000 + (result[3] || 0) * 10;
|
|
42
|
-
if (txt) {
|
|
43
|
-
this.lines.push({
|
|
44
|
-
time,
|
|
45
|
-
txt,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.lines.sort((a, b) => {
|
|
52
|
-
return a.time - b.time;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function lyricParse(lyricString) {
|
|
58
|
-
return new Lyric(lyricString);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
module.exports = {
|
|
62
|
-
Lyric,
|
|
63
|
-
lyricParse,
|
|
64
|
-
};
|
|
1
|
+
// [01:27.96]
|
|
2
|
+
const timeExp = /\[(\d{2,}):(\d{2})(?:\.(\d{2,3}))?]/g;
|
|
3
|
+
|
|
4
|
+
const TAGREGMAP = {
|
|
5
|
+
title: 'ti',
|
|
6
|
+
artist: 'ar',
|
|
7
|
+
album: 'al',
|
|
8
|
+
offset: 'offset',
|
|
9
|
+
by: 'by',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
class Lyric {
|
|
13
|
+
constructor(lyric) {
|
|
14
|
+
this.lyric = lyric;
|
|
15
|
+
this.tags = {};
|
|
16
|
+
this.lines = [];
|
|
17
|
+
|
|
18
|
+
this._init();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_init() {
|
|
22
|
+
this._initTag();
|
|
23
|
+
|
|
24
|
+
this._initLines();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_initTag() {
|
|
28
|
+
for (const tag in TAGREGMAP) {
|
|
29
|
+
const matches = this.lyric.match(new RegExp(`\\[${TAGREGMAP[tag]}:([^\\]]*)]`, 'i'));
|
|
30
|
+
this.tags[tag] = (matches && matches[1]) || '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_initLines() {
|
|
35
|
+
const lines = this.lyric.split('\n');
|
|
36
|
+
for (let i = 0; i < lines.length; i++) {
|
|
37
|
+
const line = lines[i];
|
|
38
|
+
const result = timeExp.exec(line);
|
|
39
|
+
if (result) {
|
|
40
|
+
const txt = line.replace(timeExp, '').trim();
|
|
41
|
+
const time = result[1] * 60 * 1000 + result[2] * 1000 + (result[3] || 0) * 10;
|
|
42
|
+
if (txt) {
|
|
43
|
+
this.lines.push({
|
|
44
|
+
time,
|
|
45
|
+
txt,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.lines.sort((a, b) => {
|
|
52
|
+
return a.time - b.time;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function lyricParse(lyricString) {
|
|
58
|
+
return new Lyric(lyricString);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
Lyric,
|
|
63
|
+
lyricParse,
|
|
64
|
+
};
|
package/util/request.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
require('../util/colors');
|
|
3
|
-
|
|
4
|
-
// `withCredentials` 表示跨域请求时是否需要使用凭证
|
|
5
|
-
axios.defaults.withCredentials = true;
|
|
6
|
-
axios.defaults.timeout = 10000;
|
|
7
|
-
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8;text/plain;';
|
|
8
|
-
axios.defaults.responseType = 'json;text/plain;charset=utf-8;';
|
|
9
|
-
|
|
10
|
-
const setHeaders = headers => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// let uURL = 'https:/u.y.qq.com/cgi-bin/musicu.fcg';
|
|
20
|
-
|
|
21
|
-
function request(url, method = 'GET', options = {}, isUUrl = 'c') {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = request;
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const colors = require('../util/colors');
|
|
3
|
+
|
|
4
|
+
// `withCredentials` 表示跨域请求时是否需要使用凭证
|
|
5
|
+
axios.defaults.withCredentials = true;
|
|
6
|
+
axios.defaults.timeout = 10000;
|
|
7
|
+
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8;text/plain;';
|
|
8
|
+
axios.defaults.responseType = 'json;text/plain;charset=utf-8;';
|
|
9
|
+
|
|
10
|
+
const setHeaders = headers => {
|
|
11
|
+
return {
|
|
12
|
+
...headers,
|
|
13
|
+
cookies: global.userInfo.cookie,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const yURL = 'https://y.qq.com';
|
|
18
|
+
const cURL = 'https://c.y.qq.com';
|
|
19
|
+
// let uURL = 'https:/u.y.qq.com/cgi-bin/musicu.fcg';
|
|
20
|
+
|
|
21
|
+
function request(url, method = 'GET', options = {}, isUUrl = 'c') {
|
|
22
|
+
let baseURL = '';
|
|
23
|
+
switch (isUUrl) {
|
|
24
|
+
case 'y':
|
|
25
|
+
baseURL = yURL + url;
|
|
26
|
+
break;
|
|
27
|
+
case 'u':
|
|
28
|
+
baseURL = url;
|
|
29
|
+
break;
|
|
30
|
+
case 'c':
|
|
31
|
+
baseURL = cURL + url;
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
baseURL = cURL + url;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
options = Object.assign(options, {
|
|
39
|
+
headers: setHeaders(options.headers || {}),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return axios[method](baseURL, options).then(
|
|
43
|
+
response => {
|
|
44
|
+
if (!response) {
|
|
45
|
+
throw Error('response is null');
|
|
46
|
+
}
|
|
47
|
+
console.log(colors.info(`${url} request success`));
|
|
48
|
+
return response;
|
|
49
|
+
},
|
|
50
|
+
error => {
|
|
51
|
+
console.log(colors.error(`${url} request error`));
|
|
52
|
+
throw error;
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = request;
|