@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.
Files changed (173) hide show
  1. package/.babelrc +4 -0
  2. package/.eslintrc.json +20 -19
  3. package/AGENTS.md +153 -0
  4. package/README.md +162 -136
  5. package/{app.js → app.ts} +24 -31
  6. package/config/user-info.ts +71 -0
  7. package/index.ts +1 -0
  8. package/{jest.config.js → jest.config.ts} +19 -7
  9. package/middlewares/koa-cors.ts +81 -0
  10. package/module/apis/UCommon/UCommon.ts +13 -0
  11. package/module/apis/album/getAlbumInfo.ts +22 -0
  12. package/module/apis/comments/getComments.ts +23 -0
  13. package/module/apis/digitalAlbum/getDigitalAlbumLists.ts +23 -0
  14. package/module/apis/downloadQQMusic.ts +51 -0
  15. package/module/apis/music/getLyric.ts +34 -0
  16. package/module/apis/mv/getMvByTag.ts +24 -0
  17. package/module/apis/radio/getRadioLists.ts +27 -0
  18. package/module/apis/rank/getTopLists.ts +37 -0
  19. package/module/apis/search/getHotKey.ts +24 -0
  20. package/module/apis/search/getSearchByKey.ts +31 -0
  21. package/module/apis/search/getSmartbox.ts +43 -0
  22. package/module/apis/singers/getSimilarSinger.ts +25 -0
  23. package/module/apis/singers/getSingerDesc.ts +25 -0
  24. package/module/apis/singers/getSingerMv.ts +24 -0
  25. package/module/apis/singers/getSingerStarNum.ts +24 -0
  26. package/module/apis/songLists/songListCategories.ts +22 -0
  27. package/module/apis/songLists/songListDetail.ts +27 -0
  28. package/module/apis/songLists/songLists.ts +35 -0
  29. package/module/apis/u_common.ts +29 -0
  30. package/module/apis/user/checkQQLoginQr.ts +230 -0
  31. package/module/apis/user/getQQLoginQr.ts +28 -0
  32. package/module/apis/user/getUserAvatar.ts +32 -0
  33. package/module/apis/user/getUserLikedSongs.ts +145 -0
  34. package/module/apis/user/getUserPlaylists.ts +163 -0
  35. package/module/apis/y_common.ts +44 -0
  36. package/module/config.ts +24 -0
  37. package/module/index.ts +95 -0
  38. package/package.json +25 -6
  39. package/pnpm-workspace.yaml +2 -0
  40. package/public/index.html +411 -29
  41. package/routers/context/batchGetSongInfo.ts +60 -0
  42. package/routers/context/batchGetSongLists.ts +46 -0
  43. package/routers/context/checkQQLoginQr.ts +19 -0
  44. package/routers/context/{cookies.js → cookies.ts} +14 -12
  45. package/routers/context/getAlbumInfo.ts +31 -0
  46. package/routers/context/getComments.ts +51 -0
  47. package/routers/context/getDigitalAlbumLists.ts +18 -0
  48. package/routers/context/getDownloadQQMusic.ts +17 -0
  49. package/routers/context/getHotkey.ts +25 -0
  50. package/routers/context/getImageUrl.ts +29 -0
  51. package/routers/context/getLyric.ts +32 -0
  52. package/routers/context/getMusicPlay.ts +102 -0
  53. package/routers/context/getMv.ts +61 -0
  54. package/routers/context/getMvByTag.ts +18 -0
  55. package/routers/context/getMvPlay.ts +114 -0
  56. package/routers/context/getNewDisks.ts +58 -0
  57. package/routers/context/getQQLoginQr.ts +16 -0
  58. package/routers/context/getRadioLists.ts +18 -0
  59. package/routers/context/getRanks.ts +67 -0
  60. package/routers/context/getRecommend.ts +92 -0
  61. package/routers/context/getSearchByKey.ts +34 -0
  62. package/routers/context/getSimilarSinger.ts +29 -0
  63. package/routers/context/getSingerAlbum.ts +58 -0
  64. package/routers/context/getSingerDesc.ts +30 -0
  65. package/routers/context/getSingerHotsong.ts +58 -0
  66. package/routers/context/getSingerList.ts +56 -0
  67. package/routers/context/getSingerMv.ts +41 -0
  68. package/routers/context/getSingerStarNum.ts +29 -0
  69. package/routers/context/getSmartbox.ts +27 -0
  70. package/routers/context/getSongInfo.ts +51 -0
  71. package/routers/context/{getSongListCategories.js → getSongListCategories.ts} +5 -4
  72. package/routers/context/getSongListDetail.ts +22 -0
  73. package/routers/context/getSongLists.ts +30 -0
  74. package/routers/context/getTicketInfo.ts +51 -0
  75. package/routers/context/getTopLists.ts +18 -0
  76. package/routers/context/getUserAvatar.ts +53 -0
  77. package/routers/context/getUserLikedSongs.ts +28 -0
  78. package/routers/context/getUserPlaylists.ts +29 -0
  79. package/routers/context/index.ts +87 -0
  80. package/routers/{router.js → router.ts} +7 -55
  81. package/routers/types.ts +18 -0
  82. package/routers/util.ts +231 -0
  83. package/tests/integration/api/api.test.ts +852 -0
  84. package/tests/integration/middleware/{cors.test.js → cors.test.ts} +7 -3
  85. package/tests/setup/jest.setup.ts +15 -0
  86. package/tests/setup/testUtils.ts +35 -0
  87. package/tests/unit/util/request.test.ts +177 -0
  88. package/tsconfig.json +20 -0
  89. package/tsconfig.test.json +8 -0
  90. package/types/api.ts +105 -0
  91. package/types/global.d.ts +26 -0
  92. package/types/index.d.ts +97 -0
  93. package/util/apiResponse.ts +97 -0
  94. package/util/colors.ts +31 -0
  95. package/util/cookie.ts +40 -0
  96. package/util/{loginUtils.js → loginUtils.ts} +3 -5
  97. package/util/lyricParse.ts +86 -0
  98. package/util/request.ts +141 -0
  99. package/.github/FUNDING.yml +0 -12
  100. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  101. package/.github/ISSUE_TEMPLATE/custom.md +0 -24
  102. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  103. package/config/user-info.js +0 -42
  104. package/index.js +0 -1
  105. package/middlewares/koa-cors.js +0 -97
  106. package/module/apis/UCommon/UCommon.js +0 -6
  107. package/module/apis/album/getAlbumInfo.js +0 -33
  108. package/module/apis/comments/getComments.js +0 -35
  109. package/module/apis/digitalAlbum/getDigitalAlbumLists.js +0 -34
  110. package/module/apis/downloadQQMusic.js +0 -41
  111. package/module/apis/music/getLyric.js +0 -41
  112. package/module/apis/mv/getMvByTag.js +0 -35
  113. package/module/apis/radio/getRadioLists.js +0 -38
  114. package/module/apis/rank/getTopLists.js +0 -44
  115. package/module/apis/search/getHotKey.js +0 -35
  116. package/module/apis/search/getSearchByKey.js +0 -45
  117. package/module/apis/search/getSmartbox.js +0 -34
  118. package/module/apis/singers/getSimilarSinger.js +0 -36
  119. package/module/apis/singers/getSingerDesc.js +0 -37
  120. package/module/apis/singers/getSingerMv.js +0 -35
  121. package/module/apis/singers/getSingerStarNum.js +0 -35
  122. package/module/apis/songLists/songListCategories.js +0 -33
  123. package/module/apis/songLists/songListDetail.js +0 -38
  124. package/module/apis/songLists/songLists.js +0 -41
  125. package/module/apis/u_common.js +0 -17
  126. package/module/apis/user/checkQQLoginQr.js +0 -125
  127. package/module/apis/user/getQQLoginQr.js +0 -17
  128. package/module/apis/y_common.js +0 -27
  129. package/module/config.js +0 -31
  130. package/module/index.js +0 -82
  131. package/routers/context/batchGetSongInfo.js +0 -59
  132. package/routers/context/batchGetSongLists.js +0 -50
  133. package/routers/context/checkQQLoginQr.js +0 -17
  134. package/routers/context/getAlbumInfo.js +0 -27
  135. package/routers/context/getComments.js +0 -51
  136. package/routers/context/getDigitalAlbumLists.js +0 -14
  137. package/routers/context/getDownloadQQMusic.js +0 -14
  138. package/routers/context/getHotkey.js +0 -14
  139. package/routers/context/getImageUrl.js +0 -34
  140. package/routers/context/getLyric.js +0 -26
  141. package/routers/context/getMusicPlay.js +0 -116
  142. package/routers/context/getMv.js +0 -56
  143. package/routers/context/getMvByTag.js +0 -15
  144. package/routers/context/getMvPlay.js +0 -128
  145. package/routers/context/getNewDisks.js +0 -50
  146. package/routers/context/getQQLoginQr.js +0 -12
  147. package/routers/context/getRadioLists.js +0 -14
  148. package/routers/context/getRanks.js +0 -103
  149. package/routers/context/getRecommend.js +0 -86
  150. package/routers/context/getSearchByKey.js +0 -33
  151. package/routers/context/getSimilarSinger.js +0 -25
  152. package/routers/context/getSingerAlbum.js +0 -52
  153. package/routers/context/getSingerDesc.js +0 -25
  154. package/routers/context/getSingerHotsong.js +0 -52
  155. package/routers/context/getSingerList.js +0 -51
  156. package/routers/context/getSingerMv.js +0 -32
  157. package/routers/context/getSingerStarNum.js +0 -24
  158. package/routers/context/getSmartbox.js +0 -24
  159. package/routers/context/getSongInfo.js +0 -49
  160. package/routers/context/getSongListDetail.js +0 -25
  161. package/routers/context/getSongLists.js +0 -32
  162. package/routers/context/getTicketInfo.js +0 -45
  163. package/routers/context/getTopLists.js +0 -15
  164. package/routers/context/index.js +0 -74
  165. package/tests/integration/api/api.test.js +0 -116
  166. package/tests/setup/jest.setup.js +0 -46
  167. package/tests/setup/testUtils.js +0 -106
  168. package/tests/unit/util/lyricParse.test.js +0 -97
  169. package/tests/unit/util/request.test.js +0 -66
  170. package/util/colors.js +0 -16
  171. package/util/cookie.js +0 -22
  172. package/util/lyricParse.js +0 -67
  173. 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
- };
@@ -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;