@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.
Files changed (94) hide show
  1. package/.babelrc +2 -2
  2. package/.dockerignore +5 -5
  3. package/.editorconfig +31 -31
  4. package/.eslintrc.json +21 -17
  5. package/.github/FUNDING.yml +12 -12
  6. package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
  7. package/.github/ISSUE_TEMPLATE/custom.md +24 -24
  8. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
  9. package/.github/workflows/publish.yml +26 -0
  10. package/.husky/commit-msg +1 -0
  11. package/.husky/pre-commit +1 -0
  12. package/.prettierignore +1 -1
  13. package/.prettierrc +9 -9
  14. package/CHANGELOG.md +70 -70
  15. package/Dockerfile +18 -18
  16. package/LICENSE +21 -21
  17. package/README.md +218 -177
  18. package/app.js +75 -75
  19. package/commitlint.config.js +20 -20
  20. package/config/user-info.js +42 -42
  21. package/index.js +1 -1
  22. package/middlewares/koa-cors.js +97 -97
  23. package/module/apis/UCommon/UCommon.js +6 -6
  24. package/module/apis/album/getAlbumInfo.js +33 -33
  25. package/module/apis/comments/getComments.js +35 -35
  26. package/module/apis/digitalAlbum/getDigitalAlbumLists.js +34 -34
  27. package/module/apis/downloadQQMusic.js +41 -41
  28. package/module/apis/music/getLyric.js +42 -41
  29. package/module/apis/mv/getMvByTag.js +35 -35
  30. package/module/apis/radio/getRadioLists.js +38 -38
  31. package/module/apis/rank/getTopLists.js +44 -44
  32. package/module/apis/search/getHotKey.js +35 -35
  33. package/module/apis/search/getSearchByKey.js +45 -45
  34. package/module/apis/search/getSmartbox.js +34 -34
  35. package/module/apis/singers/getSimilarSinger.js +36 -36
  36. package/module/apis/singers/getSingerDesc.js +38 -38
  37. package/module/apis/singers/getSingerMv.js +35 -35
  38. package/module/apis/singers/getSingerStarNum.js +36 -36
  39. package/module/apis/songLists/songListCategories.js +33 -33
  40. package/module/apis/songLists/songListDetail.js +38 -38
  41. package/module/apis/songLists/songLists.js +41 -41
  42. package/module/apis/u_common.js +17 -16
  43. package/module/apis/user/checkQQLoginQr.js +125 -86
  44. package/module/apis/user/getQQLoginQr.js +17 -11
  45. package/module/apis/y_common.js +27 -14
  46. package/module/config.js +31 -31
  47. package/module/index.js +82 -82
  48. package/package.json +72 -83
  49. package/public/index.html +47 -47
  50. package/routers/context/batchGetSongInfo.js +59 -59
  51. package/routers/context/batchGetSongLists.js +50 -50
  52. package/routers/context/checkQQLoginQr.js +17 -15
  53. package/routers/context/cookies.js +36 -36
  54. package/routers/context/getAlbumInfo.js +27 -27
  55. package/routers/context/getComments.js +51 -51
  56. package/routers/context/getDigitalAlbumLists.js +14 -14
  57. package/routers/context/getDownloadQQMusic.js +14 -14
  58. package/routers/context/getHotkey.js +14 -14
  59. package/routers/context/getImageUrl.js +34 -34
  60. package/routers/context/getLyric.js +26 -26
  61. package/routers/context/getMusicPlay.js +116 -112
  62. package/routers/context/getMv.js +56 -56
  63. package/routers/context/getMvByTag.js +15 -15
  64. package/routers/context/getMvPlay.js +128 -118
  65. package/routers/context/getNewDisks.js +50 -51
  66. package/routers/context/getQQLoginQr.js +12 -12
  67. package/routers/context/getRadioLists.js +14 -14
  68. package/routers/context/getRanks.js +90 -86
  69. package/routers/context/getRecommend.js +86 -86
  70. package/routers/context/getSearchByKey.js +32 -32
  71. package/routers/context/getSimilarSinger.js +25 -25
  72. package/routers/context/getSingerAlbum.js +52 -52
  73. package/routers/context/getSingerDesc.js +25 -25
  74. package/routers/context/getSingerHotsong.js +52 -52
  75. package/routers/context/getSingerList.js +51 -52
  76. package/routers/context/getSingerMv.js +32 -32
  77. package/routers/context/getSingerStarNum.js +24 -24
  78. package/routers/context/getSmartbox.js +24 -24
  79. package/routers/context/getSongInfo.js +49 -49
  80. package/routers/context/getSongListCategories.js +22 -22
  81. package/routers/context/getSongListDetail.js +25 -25
  82. package/routers/context/getSongLists.js +32 -32
  83. package/routers/context/getTicketInfo.js +45 -45
  84. package/routers/context/getTopLists.js +15 -15
  85. package/routers/context/index.js +74 -74
  86. package/routers/router.js +116 -112
  87. package/scripts/build-images.js +36 -36
  88. package/scripts/commit-push.sh +103 -103
  89. package/util/colors.js +16 -16
  90. package/util/cookie.js +22 -22
  91. package/util/loginUtils.js +28 -23
  92. package/util/lyricParse.js +64 -64
  93. package/util/request.js +57 -57
  94. package/vercel.json +15 -15
@@ -1,42 +1,42 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
-
4
- let userInfo, cookieList, cookieObject;
5
- const infoPath = path.join(__dirname, './user-info.json');
6
- fs.existsSync(infoPath) || fs.writeFileSync(infoPath, '{}', 'utf-8');
7
-
8
- const initData = () => {
9
-
10
- userInfo = { loginUin: '', cookie: '', ...JSON.parse(fs.readFileSync(infoPath, 'utf-8')) };
11
- cookieList = userInfo.cookie.split('; ').map(_ => _.trim());
12
-
13
- cookieObject = {};
14
- cookieList.filter(Boolean).forEach(_ => {
15
- if (_) {
16
- const [key, value = ''] = _.split('=');
17
-
18
- cookieObject[key] = value;
19
- }
20
- });
21
- };
22
-
23
- const refreshData = cookie => {
24
- const uin = cookie.match(/ uin=([^;]+)/)[1];
25
- fs.writeFileSync(infoPath, JSON.stringify({ loginUin: uin, cookie: cookie }), 'utf-8');
26
- initData();
27
- return {
28
- ...userInfo,
29
- uin: userInfo.loginUin || cookieObject.uin,
30
- cookieList,
31
- cookieObject
32
- };
33
- };
34
-
35
- initData();
36
-
37
- module.exports = Object.assign(userInfo, {
38
- uin: userInfo.loginUin || cookieObject.uin,
39
- cookieList,
40
- cookieObject,
41
- refreshData
42
- });
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+
4
+ let userInfo, cookieList, cookieObject;
5
+ const infoPath = path.join(__dirname, './user-info.json');
6
+ fs.existsSync(infoPath) || fs.writeFileSync(infoPath, '{}', 'utf-8');
7
+
8
+ const initData = () => {
9
+
10
+ userInfo = { loginUin: '', cookie: '', ...JSON.parse(fs.readFileSync(infoPath, 'utf-8')) };
11
+ cookieList = userInfo.cookie.split('; ').map(_ => _.trim());
12
+
13
+ cookieObject = {};
14
+ cookieList.filter(Boolean).forEach(_ => {
15
+ if (_) {
16
+ const [key, value = ''] = _.split('=');
17
+
18
+ cookieObject[key] = value;
19
+ }
20
+ });
21
+ };
22
+
23
+ const refreshData = cookie => {
24
+ const uin = cookie.match(/ uin=([^;]+)/)[1];
25
+ fs.writeFileSync(infoPath, JSON.stringify({ loginUin: uin, cookie: cookie }), 'utf-8');
26
+ initData();
27
+ return {
28
+ ...userInfo,
29
+ uin: userInfo.loginUin || cookieObject.uin,
30
+ cookieList,
31
+ cookieObject
32
+ };
33
+ };
34
+
35
+ initData();
36
+
37
+ module.exports = Object.assign(userInfo, {
38
+ uin: userInfo.loginUin || cookieObject.uin,
39
+ cookieList,
40
+ cookieObject,
41
+ refreshData
42
+ });
package/index.js CHANGED
@@ -1 +1 @@
1
- require('./app.js')
1
+ require('./app.js')
@@ -1,97 +1,97 @@
1
- /**
2
- * CORS middleware for koa2: https://github.com/zadzbw/koa2-cors/blob/master/src/index.js
3
- *
4
- * @param {Object} [options]
5
- * - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is request Origin header
6
- * - {Array} exposeHeaders `Access-Control-Expose-Headers`
7
- * - {String|Number} maxAge `Access-Control-Max-Age` in seconds
8
- * - {Boolean} credentials `Access-Control-Allow-Credentials`
9
- * - {Array} allowMethods `Access-Control-Allow-Methods`,
10
- * default is ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']
11
- * - {Array} allowHeaders `Access-Control-Allow-Headers`
12
- * @return {Function}
13
- * @api public
14
- */
15
- module.exports = function crossOrigin(options = {}) {
16
- const defaultOptions = {
17
- allowMethods: ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
18
- };
19
-
20
- // set defaultOptions to options
21
- options = Object.assign({}, defaultOptions, options); // eslint-disable-line no-param-reassign
22
-
23
- // eslint-disable-next-line consistent-return
24
- return async function cors(ctx, next) {
25
- // always set vary Origin Header
26
- // https://github.com/rs/cors/issues/10
27
- ctx.vary('Origin');
28
-
29
- let origin;
30
- if (typeof options.origin === 'function') {
31
- origin = options.origin(ctx);
32
- } else {
33
- origin = options.origin || ctx.get('Origin') || '*';
34
- }
35
- if (!origin) {
36
- return await next();
37
- }
38
-
39
- // Access-Control-Allow-Origin
40
- ctx.set('Access-Control-Allow-Origin', origin);
41
-
42
- if (ctx.method === 'OPTIONS') {
43
- // Preflight Request
44
- if (!ctx.get('Access-Control-Request-Method')) {
45
- return await next();
46
- }
47
-
48
- // Access-Control-Max-Age
49
- if (options.maxAge) {
50
- ctx.set('Access-Control-Max-Age', String(options.maxAge));
51
- }
52
-
53
- // Access-Control-Allow-Credentials
54
- if (options.credentials === true) {
55
- // When used as part of a response to a preflight request,
56
- // this indicates whether or not the actual request can be made using credentials.
57
- ctx.set('Access-Control-Allow-Credentials', 'true');
58
- }
59
-
60
- // Access-Control-Allow-Methods
61
- if (options.allowMethods) {
62
- ctx.set('Access-Control-Allow-Methods', options.allowMethods.join(','));
63
- }
64
-
65
- // Access-Control-Allow-Headers
66
- if (options.allowHeaders) {
67
- ctx.set('Access-Control-Allow-Headers', options.allowHeaders.join(','));
68
- } else {
69
- ctx.set('Access-Control-Allow-Headers', ctx.get('Access-Control-Request-Headers'));
70
- }
71
-
72
- ctx.status = 204; // No Content
73
- } else {
74
- // Request
75
- // Access-Control-Allow-Credentials
76
- if (options.credentials === true) {
77
- if (origin === '*') {
78
- // `credentials` can't be true when the `origin` is set to `*`
79
- ctx.remove('Access-Control-Allow-Credentials');
80
- } else {
81
- ctx.set('Access-Control-Allow-Credentials', 'true');
82
- }
83
- }
84
-
85
- // Access-Control-Expose-Headers
86
- if (options.exposeHeaders) {
87
- ctx.set('Access-Control-Expose-Headers', options.exposeHeaders.join(','));
88
- }
89
-
90
- try {
91
- await next();
92
- } catch (err) {
93
- throw err;
94
- }
95
- }
96
- };
97
- };
1
+ /**
2
+ * CORS middleware for koa2: https://github.com/zadzbw/koa2-cors/blob/master/src/index.js
3
+ *
4
+ * @param {Object} [options]
5
+ * - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is request Origin header
6
+ * - {Array} exposeHeaders `Access-Control-Expose-Headers`
7
+ * - {String|Number} maxAge `Access-Control-Max-Age` in seconds
8
+ * - {Boolean} credentials `Access-Control-Allow-Credentials`
9
+ * - {Array} allowMethods `Access-Control-Allow-Methods`,
10
+ * default is ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']
11
+ * - {Array} allowHeaders `Access-Control-Allow-Headers`
12
+ * @return {Function}
13
+ * @api public
14
+ */
15
+ module.exports = function crossOrigin(options = {}) {
16
+ const defaultOptions = {
17
+ allowMethods: ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
18
+ };
19
+
20
+ // set defaultOptions to options
21
+ options = Object.assign({}, defaultOptions, options); // eslint-disable-line no-param-reassign
22
+
23
+ // eslint-disable-next-line consistent-return
24
+ return async function cors(ctx, next) {
25
+ // always set vary Origin Header
26
+ // https://github.com/rs/cors/issues/10
27
+ ctx.vary('Origin');
28
+
29
+ let origin;
30
+ if (typeof options.origin === 'function') {
31
+ origin = options.origin(ctx);
32
+ } else {
33
+ origin = options.origin || ctx.get('Origin') || '*';
34
+ }
35
+ if (!origin) {
36
+ return await next();
37
+ }
38
+
39
+ // Access-Control-Allow-Origin
40
+ ctx.set('Access-Control-Allow-Origin', origin);
41
+
42
+ if (ctx.method === 'OPTIONS') {
43
+ // Preflight Request
44
+ if (!ctx.get('Access-Control-Request-Method')) {
45
+ return await next();
46
+ }
47
+
48
+ // Access-Control-Max-Age
49
+ if (options.maxAge) {
50
+ ctx.set('Access-Control-Max-Age', String(options.maxAge));
51
+ }
52
+
53
+ // Access-Control-Allow-Credentials
54
+ if (options.credentials === true) {
55
+ // When used as part of a response to a preflight request,
56
+ // this indicates whether or not the actual request can be made using credentials.
57
+ ctx.set('Access-Control-Allow-Credentials', 'true');
58
+ }
59
+
60
+ // Access-Control-Allow-Methods
61
+ if (options.allowMethods) {
62
+ ctx.set('Access-Control-Allow-Methods', options.allowMethods.join(','));
63
+ }
64
+
65
+ // Access-Control-Allow-Headers
66
+ if (options.allowHeaders) {
67
+ ctx.set('Access-Control-Allow-Headers', options.allowHeaders.join(','));
68
+ } else {
69
+ ctx.set('Access-Control-Allow-Headers', ctx.get('Access-Control-Request-Headers'));
70
+ }
71
+
72
+ ctx.status = 204; // No Content
73
+ } else {
74
+ // Request
75
+ // Access-Control-Allow-Credentials
76
+ if (options.credentials === true) {
77
+ if (origin === '*') {
78
+ // `credentials` can't be true when the `origin` is set to `*`
79
+ ctx.remove('Access-Control-Allow-Credentials');
80
+ } else {
81
+ ctx.set('Access-Control-Allow-Credentials', 'true');
82
+ }
83
+ }
84
+
85
+ // Access-Control-Expose-Headers
86
+ if (options.exposeHeaders) {
87
+ ctx.set('Access-Control-Expose-Headers', options.exposeHeaders.join(','));
88
+ }
89
+
90
+ try {
91
+ await next();
92
+ } catch (err) {
93
+ throw err;
94
+ }
95
+ }
96
+ };
97
+ };
@@ -1,6 +1,6 @@
1
- const u_common = require('../u_common');
2
-
3
- module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
- let options = Object.assign(option, { params });
5
- return u_common({ method, options });
6
- };
1
+ const u_common = require('../u_common');
2
+
3
+ module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
+ const options = Object.assign(option, { params });
5
+ return u_common({ method, options });
6
+ };
@@ -1,33 +1,33 @@
1
- const y_common = require('../y_common');
2
-
3
- module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
- const data = Object.assign(params, {
5
- format: 'json',
6
- outCharset: 'utf-8',
7
- });
8
- const options = Object.assign(option, {
9
- params: data,
10
- });
11
- return y_common({
12
- url: '/v8/fcg-bin/fcg_v8_album_info_cp.fcg',
13
- method,
14
- options,
15
- })
16
- .then(res => {
17
- const response = res.data;
18
- return {
19
- status: 200,
20
- body: {
21
- response,
22
- },
23
- };
24
- })
25
- .catch(error => {
26
- console.log('error', error);
27
- return {
28
- body: {
29
- error,
30
- },
31
- };
32
- });
33
- };
1
+ const y_common = require('../y_common');
2
+
3
+ module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
+ const data = Object.assign(params, {
5
+ format: 'json',
6
+ outCharset: 'utf-8',
7
+ });
8
+ const options = Object.assign(option, {
9
+ params: data,
10
+ });
11
+ return y_common({
12
+ url: '/v8/fcg-bin/fcg_v8_album_info_cp.fcg',
13
+ method,
14
+ options,
15
+ })
16
+ .then(res => {
17
+ const response = res.data;
18
+ return {
19
+ status: 200,
20
+ body: {
21
+ response,
22
+ },
23
+ };
24
+ })
25
+ .catch(error => {
26
+ console.log('error', error);
27
+ return {
28
+ body: {
29
+ error,
30
+ },
31
+ };
32
+ });
33
+ };
@@ -1,35 +1,35 @@
1
- const y_common = require('../y_common');
2
-
3
- module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
- const data = Object.assign(params, {
5
- format: 'json',
6
- outCharset: 'GB2312',
7
- domain: 'qq.com',
8
- ct: 24,
9
- cv: 10101010,
10
- needmusiccrit: 0,
11
- });
12
- const options = Object.assign(option, { params: data });
13
- return y_common({
14
- url: '/base/fcgi-bin/fcg_global_comment_h5.fcg',
15
- method,
16
- options,
17
- })
18
- .then(res => {
19
- const response = res.data;
20
- return {
21
- status: 200,
22
- body: {
23
- response,
24
- },
25
- };
26
- })
27
- .catch(error => {
28
- console.log('error', error);
29
- return {
30
- body: {
31
- error,
32
- },
33
- };
34
- });
35
- };
1
+ const y_common = require('../y_common');
2
+
3
+ module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
+ const data = Object.assign(params, {
5
+ format: 'json',
6
+ outCharset: 'GB2312',
7
+ domain: 'qq.com',
8
+ ct: 24,
9
+ cv: 10101010,
10
+ needmusiccrit: 0,
11
+ });
12
+ const options = Object.assign(option, { params: data });
13
+ return y_common({
14
+ url: '/base/fcgi-bin/fcg_global_comment_h5.fcg',
15
+ method,
16
+ options,
17
+ })
18
+ .then(res => {
19
+ const response = res.data;
20
+ return {
21
+ status: 200,
22
+ body: {
23
+ response,
24
+ },
25
+ };
26
+ })
27
+ .catch(error => {
28
+ console.log('error', error);
29
+ return {
30
+ body: {
31
+ error,
32
+ },
33
+ };
34
+ });
35
+ };
@@ -1,34 +1,34 @@
1
- const y_common = require('../y_common');
2
-
3
- module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
- const data = Object.assign(params, {
5
- format: 'json',
6
- outCharset: 'utf-8',
7
- cmd: 'pc_index_new',
8
- });
9
- const options = Object.assign(option, {
10
- params: data,
11
- });
12
- return y_common({
13
- url: '/v8/fcg-bin/musicmall.fcg',
14
- method,
15
- options,
16
- })
17
- .then(res => {
18
- const response = res.data;
19
- return {
20
- status: 200,
21
- body: {
22
- response,
23
- },
24
- };
25
- })
26
- .catch(error => {
27
- console.log('error', error);
28
- return {
29
- body: {
30
- error,
31
- },
32
- };
33
- });
34
- };
1
+ const y_common = require('../y_common');
2
+
3
+ module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
+ const data = Object.assign(params, {
5
+ format: 'json',
6
+ outCharset: 'utf-8',
7
+ cmd: 'pc_index_new',
8
+ });
9
+ const options = Object.assign(option, {
10
+ params: data,
11
+ });
12
+ return y_common({
13
+ url: '/v8/fcg-bin/musicmall.fcg',
14
+ method,
15
+ options,
16
+ })
17
+ .then(res => {
18
+ const response = res.data;
19
+ return {
20
+ status: 200,
21
+ body: {
22
+ response,
23
+ },
24
+ };
25
+ })
26
+ .catch(error => {
27
+ console.log('error', error);
28
+ return {
29
+ body: {
30
+ error,
31
+ },
32
+ };
33
+ });
34
+ };
@@ -1,41 +1,41 @@
1
- const request = require('../../util/request');
2
-
3
- module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
- const data = Object.assign(params, {
5
- format: 'jsonp',
6
- jsonpCallback: 'MusicJsonCallback',
7
- platform: 'yqq',
8
- });
9
- const options = Object.assign(option, {
10
- headers: {
11
- host: 'y.qq.com',
12
- referer: 'https://y.qq.com/',
13
- },
14
- params: data,
15
- });
16
- return request('/download/download.js', method, options, 'y')
17
- .then(res => {
18
- let response = res.data;
19
- if (typeof response === 'string') {
20
- const reg = /^\w+\(({[^()]+})\)$/;
21
- const matches = response.match(reg);
22
- if (matches) {
23
- response = JSON.parse(matches[1]);
24
- }
25
- }
26
- return {
27
- status: 200,
28
- body: {
29
- response,
30
- },
31
- };
32
- })
33
- .catch(error => {
34
- console.log('error', error);
35
- return {
36
- body: {
37
- error,
38
- },
39
- };
40
- });
41
- };
1
+ const request = require('../../util/request');
2
+
3
+ module.exports = ({ method = 'get', params = {}, option = {} }) => {
4
+ const data = Object.assign(params, {
5
+ format: 'jsonp',
6
+ jsonpCallback: 'MusicJsonCallback',
7
+ platform: 'yqq',
8
+ });
9
+ const options = Object.assign(option, {
10
+ headers: {
11
+ host: 'y.qq.com',
12
+ referer: 'https://y.qq.com/',
13
+ },
14
+ params: data,
15
+ });
16
+ return request('/download/download.js', method, options, 'y')
17
+ .then(res => {
18
+ let response = res.data;
19
+ if (typeof response === 'string') {
20
+ const reg = /^\w+\(({[^()]+})\)$/;
21
+ const matches = response.match(reg);
22
+ if (matches) {
23
+ response = JSON.parse(matches[1]);
24
+ }
25
+ }
26
+ return {
27
+ status: 200,
28
+ body: {
29
+ response,
30
+ },
31
+ };
32
+ })
33
+ .catch(error => {
34
+ console.log('error', error);
35
+ return {
36
+ body: {
37
+ error,
38
+ },
39
+ };
40
+ });
41
+ };
@@ -1,41 +1,42 @@
1
- const { lyricParse } = require('../../../util/lyricParse');
2
- const moment = require('moment');
3
- const y_common = require('../y_common');
4
-
5
- module.exports = ({ method = 'get', params = {}, option = {}, isFormat = false }) => {
6
- const data = Object.assign(params, {
7
- format: 'json',
8
- outCharset: 'utf-8',
9
- pcachetime: moment().valueOf(),
10
- });
11
- const options = Object.assign(option, {
12
- params: data,
13
- });
14
- return y_common({
15
- url: '/lyric/fcgi-bin/fcg_query_lyric_new.fcg',
16
- method,
17
- options,
18
- })
19
- .then(res => {
20
- const lyricString = res.data && res.data.lyric && new Buffer.from(res.data.lyric, 'base64').toString();
21
- const lyric = isFormat ? lyricParse(lyricString) : lyricString;
22
- const response = {
23
- ...res.data,
24
- lyric,
25
- };
26
- return {
27
- status: 200,
28
- body: {
29
- response,
30
- },
31
- };
32
- })
33
- .catch(error => {
34
- console.log('error', error);
35
- return {
36
- body: {
37
- error,
38
- },
39
- };
40
- });
41
- };
1
+ const { lyricParse } = require('../../../util/lyricParse');
2
+ const dayjs = require('dayjs');
3
+ const y_common = require('../y_common');
4
+
5
+ module.exports = ({ method = 'get', params = {}, option = {}, isFormat = false }) => {
6
+ const data = Object.assign(params, {
7
+ format: 'json',
8
+ outCharset: 'utf-8',
9
+ pcachetime: dayjs().valueOf(),
10
+ });
11
+ const options = Object.assign(option, {
12
+ params: data,
13
+ });
14
+ return y_common({
15
+ url: '/lyric/fcgi-bin/fcg_query_lyric_new.fcg',
16
+ method,
17
+ options,
18
+ })
19
+ .then(res => {
20
+ const lyricString = res.data && res.data.lyric && Buffer.from(res.data.lyric, 'base64').toString();
21
+ const lyric = isFormat && lyricString ? lyricParse(lyricString) : lyricString;
22
+ const response = {
23
+ ...res.data,
24
+ lyric,
25
+ };
26
+ return {
27
+ status: 200,
28
+ body: {
29
+ response,
30
+ },
31
+ };
32
+ })
33
+ .catch(error => {
34
+ console.log('error', error);
35
+ return {
36
+ status: 500,
37
+ body: {
38
+ error,
39
+ },
40
+ };
41
+ });
42
+ };