@sansenjian/qq-music-api 2.1.1 → 2.2.1
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 +4 -0
- package/.eslintrc.json +20 -19
- package/AGENTS.md +153 -0
- package/README.md +162 -136
- package/{app.js → app.ts} +24 -31
- package/config/user-info.ts +71 -0
- package/index.ts +1 -0
- package/{jest.config.js → jest.config.ts} +19 -7
- package/middlewares/koa-cors.ts +81 -0
- package/module/apis/UCommon/UCommon.ts +13 -0
- package/module/apis/album/getAlbumInfo.ts +22 -0
- package/module/apis/comments/getComments.ts +23 -0
- package/module/apis/digitalAlbum/getDigitalAlbumLists.ts +23 -0
- package/module/apis/downloadQQMusic.ts +51 -0
- package/module/apis/music/getLyric.ts +34 -0
- package/module/apis/mv/getMvByTag.ts +24 -0
- package/module/apis/radio/getRadioLists.ts +27 -0
- package/module/apis/rank/getTopLists.ts +37 -0
- package/module/apis/search/getHotKey.ts +24 -0
- package/module/apis/search/getSearchByKey.ts +31 -0
- package/module/apis/search/getSmartbox.ts +43 -0
- package/module/apis/singers/getSimilarSinger.ts +25 -0
- package/module/apis/singers/getSingerDesc.ts +25 -0
- package/module/apis/singers/getSingerMv.ts +24 -0
- package/module/apis/singers/getSingerStarNum.ts +24 -0
- package/module/apis/songLists/songListCategories.ts +22 -0
- package/module/apis/songLists/songListDetail.ts +27 -0
- package/module/apis/songLists/songLists.ts +35 -0
- package/module/apis/u_common.ts +29 -0
- package/module/apis/user/checkQQLoginQr.ts +230 -0
- package/module/apis/user/getQQLoginQr.ts +28 -0
- package/module/apis/user/getUserAvatar.ts +32 -0
- package/module/apis/user/getUserLikedSongs.ts +145 -0
- package/module/apis/user/getUserPlaylists.ts +163 -0
- package/module/apis/y_common.ts +44 -0
- package/module/config.ts +24 -0
- package/module/index.ts +95 -0
- package/package.json +25 -6
- package/pnpm-workspace.yaml +2 -0
- package/public/index.html +411 -29
- package/routers/context/batchGetSongInfo.ts +60 -0
- package/routers/context/batchGetSongLists.ts +46 -0
- package/routers/context/checkQQLoginQr.ts +19 -0
- package/routers/context/{cookies.js → cookies.ts} +14 -12
- package/routers/context/getAlbumInfo.ts +31 -0
- package/routers/context/getComments.ts +51 -0
- package/routers/context/getDigitalAlbumLists.ts +18 -0
- package/routers/context/getDownloadQQMusic.ts +17 -0
- package/routers/context/getHotkey.ts +25 -0
- package/routers/context/getImageUrl.ts +29 -0
- package/routers/context/getLyric.ts +32 -0
- package/routers/context/getMusicPlay.ts +102 -0
- package/routers/context/getMv.ts +61 -0
- package/routers/context/getMvByTag.ts +18 -0
- package/routers/context/getMvPlay.ts +114 -0
- package/routers/context/getNewDisks.ts +58 -0
- package/routers/context/getQQLoginQr.ts +16 -0
- package/routers/context/getRadioLists.ts +18 -0
- package/routers/context/getRanks.ts +67 -0
- package/routers/context/getRecommend.ts +92 -0
- package/routers/context/getSearchByKey.ts +34 -0
- package/routers/context/getSimilarSinger.ts +29 -0
- package/routers/context/getSingerAlbum.ts +58 -0
- package/routers/context/getSingerDesc.ts +30 -0
- package/routers/context/getSingerHotsong.ts +58 -0
- package/routers/context/getSingerList.ts +56 -0
- package/routers/context/getSingerMv.ts +41 -0
- package/routers/context/getSingerStarNum.ts +29 -0
- package/routers/context/getSmartbox.ts +27 -0
- package/routers/context/getSongInfo.ts +51 -0
- package/routers/context/{getSongListCategories.js → getSongListCategories.ts} +5 -4
- package/routers/context/getSongListDetail.ts +22 -0
- package/routers/context/getSongLists.ts +30 -0
- package/routers/context/getTicketInfo.ts +51 -0
- package/routers/context/getTopLists.ts +18 -0
- package/routers/context/getUserAvatar.ts +53 -0
- package/routers/context/getUserLikedSongs.ts +28 -0
- package/routers/context/getUserPlaylists.ts +29 -0
- package/routers/context/index.ts +87 -0
- package/routers/{router.js → router.ts} +7 -55
- package/routers/types.ts +18 -0
- package/routers/util.ts +231 -0
- package/tests/integration/api/api.test.ts +852 -0
- package/tests/integration/middleware/{cors.test.js → cors.test.ts} +7 -3
- package/tests/setup/jest.setup.ts +15 -0
- package/tests/setup/testUtils.ts +35 -0
- package/tests/unit/util/request.test.ts +177 -0
- package/tsconfig.json +20 -0
- package/tsconfig.test.json +8 -0
- package/types/api.ts +105 -0
- package/types/global.d.ts +26 -0
- package/types/index.d.ts +97 -0
- package/util/apiResponse.ts +97 -0
- package/util/colors.ts +31 -0
- package/util/cookie.ts +40 -0
- package/util/{loginUtils.js → loginUtils.ts} +3 -5
- package/util/lyricParse.ts +86 -0
- package/util/request.ts +141 -0
- package/.github/FUNDING.yml +0 -12
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/custom.md +0 -24
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/config/user-info.js +0 -42
- package/index.js +0 -1
- package/middlewares/koa-cors.js +0 -97
- package/module/apis/UCommon/UCommon.js +0 -6
- package/module/apis/album/getAlbumInfo.js +0 -33
- package/module/apis/comments/getComments.js +0 -35
- package/module/apis/digitalAlbum/getDigitalAlbumLists.js +0 -34
- package/module/apis/downloadQQMusic.js +0 -41
- package/module/apis/music/getLyric.js +0 -41
- package/module/apis/mv/getMvByTag.js +0 -35
- package/module/apis/radio/getRadioLists.js +0 -38
- package/module/apis/rank/getTopLists.js +0 -44
- package/module/apis/search/getHotKey.js +0 -35
- package/module/apis/search/getSearchByKey.js +0 -45
- package/module/apis/search/getSmartbox.js +0 -34
- package/module/apis/singers/getSimilarSinger.js +0 -36
- package/module/apis/singers/getSingerDesc.js +0 -37
- package/module/apis/singers/getSingerMv.js +0 -35
- package/module/apis/singers/getSingerStarNum.js +0 -35
- package/module/apis/songLists/songListCategories.js +0 -33
- package/module/apis/songLists/songListDetail.js +0 -38
- package/module/apis/songLists/songLists.js +0 -41
- package/module/apis/u_common.js +0 -17
- package/module/apis/user/checkQQLoginQr.js +0 -125
- package/module/apis/user/getQQLoginQr.js +0 -17
- package/module/apis/y_common.js +0 -27
- package/module/config.js +0 -31
- package/module/index.js +0 -82
- package/routers/context/batchGetSongInfo.js +0 -59
- package/routers/context/batchGetSongLists.js +0 -50
- package/routers/context/checkQQLoginQr.js +0 -17
- package/routers/context/getAlbumInfo.js +0 -27
- package/routers/context/getComments.js +0 -51
- package/routers/context/getDigitalAlbumLists.js +0 -14
- package/routers/context/getDownloadQQMusic.js +0 -14
- package/routers/context/getHotkey.js +0 -14
- package/routers/context/getImageUrl.js +0 -34
- package/routers/context/getLyric.js +0 -26
- package/routers/context/getMusicPlay.js +0 -116
- package/routers/context/getMv.js +0 -56
- package/routers/context/getMvByTag.js +0 -15
- package/routers/context/getMvPlay.js +0 -128
- package/routers/context/getNewDisks.js +0 -50
- package/routers/context/getQQLoginQr.js +0 -12
- package/routers/context/getRadioLists.js +0 -14
- package/routers/context/getRanks.js +0 -103
- package/routers/context/getRecommend.js +0 -86
- package/routers/context/getSearchByKey.js +0 -33
- package/routers/context/getSimilarSinger.js +0 -25
- package/routers/context/getSingerAlbum.js +0 -52
- package/routers/context/getSingerDesc.js +0 -25
- package/routers/context/getSingerHotsong.js +0 -52
- package/routers/context/getSingerList.js +0 -51
- package/routers/context/getSingerMv.js +0 -32
- package/routers/context/getSingerStarNum.js +0 -24
- package/routers/context/getSmartbox.js +0 -24
- package/routers/context/getSongInfo.js +0 -49
- package/routers/context/getSongListDetail.js +0 -25
- package/routers/context/getSongLists.js +0 -32
- package/routers/context/getTicketInfo.js +0 -45
- package/routers/context/getTopLists.js +0 -15
- package/routers/context/index.js +0 -74
- package/tests/integration/api/api.test.js +0 -116
- package/tests/setup/jest.setup.js +0 -46
- package/tests/setup/testUtils.js +0 -106
- package/tests/unit/util/lyricParse.test.js +0 -97
- package/tests/unit/util/request.test.js +0 -66
- package/util/colors.js +0 -16
- package/util/cookie.js +0 -22
- package/util/lyricParse.js +0 -67
- package/util/request.js +0 -57
package/util/colors.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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/lyricParse.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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].trim();
|
|
38
|
-
timeExp.lastIndex = 0;
|
|
39
|
-
const matches = [...line.matchAll(timeExp)];
|
|
40
|
-
if (matches.length > 0) {
|
|
41
|
-
const txt = line.replace(timeExp, '').trim();
|
|
42
|
-
if (txt) {
|
|
43
|
-
for (const result of matches) {
|
|
44
|
-
const time = result[1] * 60 * 1000 + result[2] * 1000 + (result[3] || 0) * 10;
|
|
45
|
-
this.lines.push({
|
|
46
|
-
time,
|
|
47
|
-
txt,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.lines.sort((a, b) => {
|
|
55
|
-
return a.time - b.time;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function lyricParse(lyricString) {
|
|
61
|
-
return new Lyric(lyricString);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
module.exports = {
|
|
65
|
-
Lyric,
|
|
66
|
-
lyricParse,
|
|
67
|
-
};
|
package/util/request.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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;
|