@sansenjian/qq-music-api 2.2.7 → 2.2.9

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 (116) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/README.md +2 -0
  3. package/dist/app.js +24 -5
  4. package/dist/config/service-config.js +37 -0
  5. package/dist/jest.config.js +14 -2
  6. package/dist/middlewares/fallback-middleware.js +29 -0
  7. package/dist/module/apis/music/getMusicPlay.js +187 -0
  8. package/dist/module/apis/u_common.js +8 -2
  9. package/dist/module/apis/user/getUserPlaylists.js +5 -5
  10. package/dist/module/index.js +3 -1
  11. package/dist/package.json +4 -1
  12. package/dist/routers/context/batchGetSongInfo.js +11 -16
  13. package/dist/routers/context/batchGetSongLists.js +18 -20
  14. package/dist/routers/context/getAlbumInfo.js +10 -17
  15. package/dist/routers/context/getComments.js +12 -19
  16. package/dist/routers/context/getDailyRecommend.js +5 -17
  17. package/dist/routers/context/getHotkey.js +7 -8
  18. package/dist/routers/context/getMusicPlay.js +23 -81
  19. package/dist/routers/context/getMv.js +16 -22
  20. package/dist/routers/context/getMvPlay.js +48 -49
  21. package/dist/routers/context/getPersonalRecommend.js +13 -25
  22. package/dist/routers/context/getPlaylistTags.js +20 -26
  23. package/dist/routers/context/getRanks.js +9 -16
  24. package/dist/routers/context/getSingerAlbum.js +16 -22
  25. package/dist/routers/context/getSingerHotsong.js +16 -22
  26. package/dist/routers/context/getSingerList.js +9 -21
  27. package/dist/routers/context/getSongInfo.js +9 -16
  28. package/dist/routers/context/getSongListCategories.js +6 -7
  29. package/dist/routers/context/getSongListDetail.js +6 -8
  30. package/dist/routers/context/getUserAvatar.js +20 -33
  31. package/dist/routers/context/getUserPlaylists.js +6 -3
  32. package/dist/routers/context/index.js +94 -103
  33. package/dist/routers/util.js +31 -0
  34. package/dist/scripts/run-tests-with-flags.js +139 -0
  35. package/dist/util/cookie.js +15 -7
  36. package/dist/util/cookieResolver.js +66 -0
  37. package/dist/util/request.js +15 -6
  38. package/docs-dist/404.html +2 -2
  39. package/docs-dist/CHANGELOG-ARCHITECTURE.html +6 -6
  40. package/docs-dist/COOKIE_CONFIG_GUIDE.html +6 -6
  41. package/docs-dist/FALLBACK_MODE_GUIDE.html +101 -0
  42. package/docs-dist/README.html +6 -6
  43. package/docs-dist/TEST_USER_PLAYLISTS.html +6 -6
  44. package/docs-dist/USER_AVATAR_GUIDE.html +6 -6
  45. package/docs-dist/api/comments.html +6 -6
  46. package/docs-dist/api/index.html +6 -6
  47. package/docs-dist/api/music.html +6 -6
  48. package/docs-dist/api/other.html +6 -6
  49. package/docs-dist/api/playlist.html +6 -6
  50. package/docs-dist/api/rank.html +6 -6
  51. package/docs-dist/api/search.html +6 -6
  52. package/docs-dist/api/singer.html +6 -6
  53. package/docs-dist/api/user.html +6 -6
  54. package/docs-dist/assets/{CHANGELOG-ARCHITECTURE.md.BOe0ZtyR.js → CHANGELOG-ARCHITECTURE.md.r40JGJZK.js} +1 -1
  55. package/docs-dist/assets/{CHANGELOG-ARCHITECTURE.md.BOe0ZtyR.lean.js → CHANGELOG-ARCHITECTURE.md.r40JGJZK.lean.js} +1 -1
  56. package/docs-dist/assets/{COOKIE_CONFIG_GUIDE.md.D68AwXR2.js → COOKIE_CONFIG_GUIDE.md.BVXl7WHu.js} +1 -1
  57. package/docs-dist/assets/{COOKIE_CONFIG_GUIDE.md.D68AwXR2.lean.js → COOKIE_CONFIG_GUIDE.md.BVXl7WHu.lean.js} +1 -1
  58. package/docs-dist/assets/FALLBACK_MODE_GUIDE.md.BBdcIdh_.js +75 -0
  59. package/docs-dist/assets/FALLBACK_MODE_GUIDE.md.BBdcIdh_.lean.js +1 -0
  60. package/docs-dist/assets/{README.md.ZJQGJ1Gb.js → README.md.D6Tw0nRd.js} +1 -1
  61. package/docs-dist/assets/{README.md.ZJQGJ1Gb.lean.js → README.md.D6Tw0nRd.lean.js} +1 -1
  62. package/docs-dist/assets/{TEST_USER_PLAYLISTS.md.C02575X2.js → TEST_USER_PLAYLISTS.md.DSt20Igj.js} +1 -1
  63. package/docs-dist/assets/{TEST_USER_PLAYLISTS.md.C02575X2.lean.js → TEST_USER_PLAYLISTS.md.DSt20Igj.lean.js} +1 -1
  64. package/docs-dist/assets/{USER_AVATAR_GUIDE.md.BOqjn5Cm.js → USER_AVATAR_GUIDE.md.CVHPs2Dn.js} +1 -1
  65. package/docs-dist/assets/{USER_AVATAR_GUIDE.md.BOqjn5Cm.lean.js → USER_AVATAR_GUIDE.md.CVHPs2Dn.lean.js} +1 -1
  66. package/docs-dist/assets/{api_comments.md.DADvndEA.js → api_comments.md.79Q_C8Qp.js} +1 -1
  67. package/docs-dist/assets/{api_comments.md.DADvndEA.lean.js → api_comments.md.79Q_C8Qp.lean.js} +1 -1
  68. package/docs-dist/assets/{api_index.md.D5IASxxG.js → api_index.md.CU3By8tw.js} +1 -1
  69. package/docs-dist/assets/{api_index.md.D5IASxxG.lean.js → api_index.md.CU3By8tw.lean.js} +1 -1
  70. package/docs-dist/assets/{api_music.md.BgB8NmZq.js → api_music.md.B1AzLePX.js} +1 -1
  71. package/docs-dist/assets/{api_music.md.BgB8NmZq.lean.js → api_music.md.B1AzLePX.lean.js} +1 -1
  72. package/docs-dist/assets/{api_other.md.BkRWXX2z.js → api_other.md.DCg4bzA7.js} +1 -1
  73. package/docs-dist/assets/{api_other.md.BkRWXX2z.lean.js → api_other.md.DCg4bzA7.lean.js} +1 -1
  74. package/docs-dist/assets/{api_playlist.md.Dc0hTrZ4.js → api_playlist.md.8ACJ3QqD.js} +1 -1
  75. package/docs-dist/assets/{api_playlist.md.Dc0hTrZ4.lean.js → api_playlist.md.8ACJ3QqD.lean.js} +1 -1
  76. package/docs-dist/assets/{api_rank.md.DRisCFyT.js → api_rank.md.B8IP2ZRy.js} +1 -1
  77. package/docs-dist/assets/{api_rank.md.DRisCFyT.lean.js → api_rank.md.B8IP2ZRy.lean.js} +1 -1
  78. package/docs-dist/assets/{api_search.md.DNnMUZK0.js → api_search.md.DO9J6nvp.js} +1 -1
  79. package/docs-dist/assets/{api_search.md.DNnMUZK0.lean.js → api_search.md.DO9J6nvp.lean.js} +1 -1
  80. package/docs-dist/assets/{api_singer.md.DCmuxQkk.js → api_singer.md.CcL32xuN.js} +1 -1
  81. package/docs-dist/assets/{api_singer.md.DCmuxQkk.lean.js → api_singer.md.CcL32xuN.lean.js} +1 -1
  82. package/docs-dist/assets/{api_user.md.Cjm9GG3z.js → api_user.md.Cb7Ky3Sn.js} +1 -1
  83. package/docs-dist/assets/{api_user.md.Cjm9GG3z.lean.js → api_user.md.Cb7Ky3Sn.lean.js} +1 -1
  84. package/docs-dist/assets/{app.Dx_1wB58.js → app.CSainqD9.js} +1 -1
  85. package/docs-dist/assets/chunks/@localSearchIndexroot.BKleDIv-.js +1 -0
  86. package/docs-dist/assets/chunks/{VPLocalSearchBox.DwKWtsdX.js → VPLocalSearchBox.BUBaq7tw.js} +1 -1
  87. package/docs-dist/assets/chunks/framework.aJbMEiY9.js +19 -0
  88. package/docs-dist/assets/chunks/{theme.pGVgJ9Cx.js → theme.CzMhU0Ps.js} +2 -2
  89. package/docs-dist/assets/{guide_architecture.md.DGtNyuMH.js → guide_architecture.md.CzgqynmB.js} +1 -1
  90. package/docs-dist/assets/{guide_architecture.md.DGtNyuMH.lean.js → guide_architecture.md.CzgqynmB.lean.js} +1 -1
  91. package/docs-dist/assets/{guide_authentication.md.mtI5LfCw.js → guide_authentication.md.a8yTA8Xe.js} +1 -1
  92. package/docs-dist/assets/{guide_authentication.md.mtI5LfCw.lean.js → guide_authentication.md.a8yTA8Xe.lean.js} +1 -1
  93. package/docs-dist/assets/{guide_index.md.B-0SG46T.js → guide_index.md.BgUUL6fI.js} +1 -1
  94. package/docs-dist/assets/{guide_index.md.B-0SG46T.lean.js → guide_index.md.BgUUL6fI.lean.js} +1 -1
  95. package/docs-dist/assets/{guide_installation.md.k-KpAfxv.js → guide_installation.md.BCZ4jBl_.js} +1 -1
  96. package/docs-dist/assets/guide_installation.md.BCZ4jBl_.lean.js +1 -0
  97. package/docs-dist/assets/{guide_quickstart.md.Bff_KFOD.js → guide_quickstart.md.9-4dA6wS.js} +1 -1
  98. package/docs-dist/assets/guide_quickstart.md.9-4dA6wS.lean.js +1 -0
  99. package/docs-dist/assets/{index.md.xrs-uIyo.js → index.md.z0hAJioN.js} +1 -1
  100. package/docs-dist/assets/{index.md.xrs-uIyo.lean.js → index.md.z0hAJioN.lean.js} +1 -1
  101. package/docs-dist/assets/{reference_response-format.md.DKYTK6uJ.js → reference_response-format.md.VvQTLDZr.js} +1 -1
  102. package/docs-dist/assets/{reference_response-format.md.DKYTK6uJ.lean.js → reference_response-format.md.VvQTLDZr.lean.js} +1 -1
  103. package/docs-dist/guide/architecture.html +6 -6
  104. package/docs-dist/guide/authentication.html +6 -6
  105. package/docs-dist/guide/index.html +6 -6
  106. package/docs-dist/guide/installation.html +6 -6
  107. package/docs-dist/guide/quickstart.html +6 -6
  108. package/docs-dist/hashmap.json +1 -1
  109. package/docs-dist/index.html +5 -5
  110. package/docs-dist/reference/response-format.html +6 -6
  111. package/docs-dist/version.json +3 -3
  112. package/package.json +4 -1
  113. package/docs-dist/assets/chunks/@localSearchIndexroot.CMY5EIwU.js +0 -1
  114. package/docs-dist/assets/chunks/framework.o40iizuP.js +0 -19
  115. package/docs-dist/assets/guide_installation.md.k-KpAfxv.lean.js +0 -1
  116. package/docs-dist/assets/guide_quickstart.md.Bff_KFOD.lean.js +0 -1
@@ -7,31 +7,19 @@ exports.getDailyRecommendController = getDailyRecommendController;
7
7
  exports.getPrivateFMController = getPrivateFMController;
8
8
  exports.getNewSongsController = getNewSongsController;
9
9
  const getDailyRecommend_1 = __importDefault(require("../../module/apis/recommend/getDailyRecommend"));
10
- /**
11
- * 获取每日推荐歌曲
12
- */
10
+ const cookieResolver_1 = require("../../util/cookieResolver");
13
11
  async function getDailyRecommendController(ctx) {
14
- const { cookie } = ctx.query;
15
- // 处理数组类型,取第一个值
16
- const normalizedCookie = Array.isArray(cookie) ? cookie[0] : cookie;
17
- const result = await getDailyRecommend_1.default.getDailyRecommend(normalizedCookie);
12
+ const { cookie } = (0, cookieResolver_1.resolveRequestCookie)(ctx);
13
+ const result = await getDailyRecommend_1.default.getDailyRecommend(cookie);
18
14
  ctx.status = result.status;
19
15
  ctx.body = result.body;
20
16
  }
21
- /**
22
- * 获取私人 FM
23
- */
24
17
  async function getPrivateFMController(ctx) {
25
- const { cookie } = ctx.query;
26
- // 处理数组类型,取第一个值
27
- const normalizedCookie = Array.isArray(cookie) ? cookie[0] : cookie;
28
- const result = await getDailyRecommend_1.default.getPrivateFM(normalizedCookie);
18
+ const { cookie } = (0, cookieResolver_1.resolveRequestCookie)(ctx);
19
+ const result = await getDailyRecommend_1.default.getPrivateFM(cookie);
29
20
  ctx.status = result.status;
30
21
  ctx.body = result.body;
31
22
  }
32
- /**
33
- * 获取新歌速递
34
- */
35
23
  async function getNewSongsController(ctx) {
36
24
  const { areaId = '5', limit = '20' } = ctx.query;
37
25
  const result = await getDailyRecommend_1.default.getNewSongs(Number(areaId), Number(limit));
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- exports.default = async (ctx, next) => {
4
+ const util_1 = require("../util");
5
+ const getHotkeyController = (0, util_1.withErrorHandler)(async (ctx) => {
5
6
  const props = {
6
7
  method: 'get',
7
8
  params: {},
@@ -10,12 +11,10 @@ exports.default = async (ctx, next) => {
10
11
  if (process.env.DEBUG === 'true') {
11
12
  console.log('[getHotkey] controller props:', props);
12
13
  }
13
- const { status, body } = await (0, module_1.getHotKey)(props);
14
+ const result = await (0, module_1.getHotKey)(props);
14
15
  if (process.env.DEBUG === 'true') {
15
- console.log('[getHotkey] controller response status:', status);
16
+ console.log('[getHotkey] controller response status:', result.status);
16
17
  }
17
- Object.assign(ctx, {
18
- status,
19
- body
20
- });
21
- };
18
+ (0, util_1.setApiResponse)(ctx, result);
19
+ });
20
+ exports.default = getHotkeyController;
@@ -1,91 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- const config_1 = require("../../module/config");
5
- const ALLOWED_QUALITIES = ['m4a', 128, 320, 'ape', 'flac'];
6
- const DEFAULT_QUALITY = 128;
7
- const parseQuality = (quality) => {
8
- const parsed = parseInt(quality) || quality;
9
- return ALLOWED_QUALITIES.includes(parsed) ? parsed : DEFAULT_QUALITY;
10
- };
4
+ const cookieResolver_1 = require("../../util/cookieResolver");
11
5
  const controller = async (ctx, next) => {
12
- const uin = global.userInfo?.uin || '0';
13
- const songmid = ctx.query.songmid + '';
14
- const justPlayUrl = (ctx.query.resType || 'play') === 'play';
15
- const guid = config_1._guid || '1429839143';
16
- const { mediaId } = ctx.query;
17
- const quality = parseQuality(ctx.query.quality);
18
- const fileType = {
19
- m4a: { s: 'C400', e: '.m4a' },
20
- 128: { s: 'M500', e: '.mp3' },
21
- 320: { s: 'M800', e: '.mp3' },
22
- ape: { s: 'A000', e: '.ape' },
23
- flac: { s: 'F000', e: '.flac' }
24
- };
25
- const songmidList = songmid.split(',');
26
- const fileInfo = fileType[quality];
27
- const file = songmidList.map(_ => `${fileInfo.s}${_}${mediaId || _}${fileInfo.e}`);
28
- const data = {
29
- req_0: {
30
- module: 'vkey.GetVkeyServer',
31
- method: 'CgiGetVkey',
32
- param: {
33
- filename: file,
34
- guid,
35
- songmid: songmidList,
36
- songtype: [0],
37
- uin,
38
- loginflag: 1,
39
- platform: '20'
40
- }
6
+ const songmid = ctx.query.songmid ?? ctx.params.songmid;
7
+ const resType = Array.isArray(ctx.query.resType) ? ctx.query.resType[0] : ctx.query.resType;
8
+ const mediaId = Array.isArray(ctx.query.mediaId) ? ctx.query.mediaId[0] : ctx.query.mediaId;
9
+ const quality = Array.isArray(ctx.query.quality) ? ctx.query.quality[0] : ctx.query.quality;
10
+ const { cookie: effectiveCookie } = (0, cookieResolver_1.resolveRequestCookie)(ctx);
11
+ const headers = {};
12
+ if (effectiveCookie) {
13
+ headers.Cookie = effectiveCookie;
14
+ }
15
+ const props = {
16
+ method: 'get',
17
+ params: {
18
+ songmid,
19
+ resType,
20
+ mediaId,
21
+ quality
41
22
  },
42
- loginUin: uin,
43
- comm: {
44
- uin,
45
- format: 'json',
46
- ct: 24,
47
- cv: 0
23
+ option: {
24
+ headers
48
25
  }
49
26
  };
50
- const params = Object.assign({
51
- format: 'json',
52
- sign: 'zzannc1o6o9b4i971602f3554385022046ab796512b7012',
53
- data: JSON.stringify(data)
27
+ const { status, body } = await (0, module_1.getMusicPlay)(props);
28
+ Object.assign(ctx, {
29
+ status,
30
+ body
54
31
  });
55
- const props = {
56
- method: 'get',
57
- params,
58
- option: {}
59
- };
60
- if (songmid) {
61
- await (0, module_1.UCommon)(props)
62
- .then(res => {
63
- const response = res.data;
64
- const domain = response?.req_0?.data?.sip?.filter?.((i) => !i.startsWith('http://ws'))?.[0] ||
65
- response?.req_0?.data?.sip?.[0];
66
- const playUrl = {};
67
- (response?.req_0?.data?.midurlinfo || []).forEach((item) => {
68
- playUrl[item.songmid] = {
69
- url: item.purl ? `${domain}${item.purl}` : '',
70
- error: !item.purl ? '暂无播放链接' : undefined
71
- };
72
- });
73
- response.playUrl = playUrl;
74
- ctx.body = {
75
- data: justPlayUrl ? { playUrl } : response
76
- };
77
- })
78
- .catch(error => {
79
- console.log('error', error);
80
- });
81
- }
82
- else {
83
- ctx.status = 400;
84
- ctx.body = {
85
- data: {
86
- message: 'no songmid'
87
- }
88
- };
89
- }
90
32
  };
91
33
  exports.default = controller;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- const controller = async (ctx, next) => {
4
+ const util_1 = require("../util");
5
+ const apiResponse_1 = require("../../util/apiResponse");
6
+ const getMvController = (0, util_1.withErrorHandler)(async (ctx) => {
5
7
  const { area_id = 15, version_id = 7, limit = 20, page = 0 } = ctx.query;
6
8
  const start = (+page ? +page - 1 : 0) * +limit;
7
9
  const data = {
@@ -25,33 +27,25 @@ const controller = async (ctx, next) => {
25
27
  }
26
28
  }
27
29
  };
28
- const params = Object.assign({
30
+ const params = {
29
31
  format: 'json',
30
32
  data: JSON.stringify(data)
31
- });
33
+ };
32
34
  const props = {
33
35
  method: 'get',
34
36
  params,
35
37
  option: {}
36
38
  };
37
- if (version_id && area_id) {
38
- await (0, module_1.UCommon)(props)
39
- .then(res => {
40
- const response = res.data;
41
- ctx.status = 200;
42
- ctx.body = {
43
- response
44
- };
45
- })
46
- .catch(error => {
47
- console.log('error', error);
39
+ if (!version_id || !area_id) {
40
+ (0, util_1.setApiResponse)(ctx, {
41
+ status: 400,
42
+ body: {
43
+ response: 'version_id or area_id is null'
44
+ }
48
45
  });
46
+ return;
49
47
  }
50
- else {
51
- ctx.status = 400;
52
- ctx.body = {
53
- response: 'version_id or area_id is null'
54
- };
55
- }
56
- };
57
- exports.default = controller;
48
+ const response = await (0, module_1.UCommon)(props);
49
+ (0, util_1.setApiResponse)(ctx, (0, apiResponse_1.customResponse)({ response: response.data }, 200));
50
+ });
51
+ exports.default = getMvController;
@@ -1,8 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- const controller = async (ctx, next) => {
4
+ const util_1 = require("../util");
5
+ const apiResponse_1 = require("../../util/apiResponse");
6
+ const getMvPlayController = (0, util_1.withErrorHandler)(async (ctx) => {
5
7
  const { vid } = ctx.query;
8
+ if (!vid) {
9
+ (0, util_1.setApiResponse)(ctx, {
10
+ status: 400,
11
+ body: {
12
+ response: 'vid is null'
13
+ }
14
+ });
15
+ return;
16
+ }
6
17
  const data = {
7
18
  comm: {
8
19
  ct: 24,
@@ -44,62 +55,50 @@ const controller = async (ctx, next) => {
44
55
  }
45
56
  }
46
57
  };
47
- const params = Object.assign({
58
+ const params = {
48
59
  format: 'json',
49
60
  data: JSON.stringify(data)
50
- });
61
+ };
51
62
  const props = {
52
63
  method: 'get',
53
64
  params,
54
65
  option: {}
55
66
  };
56
- if (vid) {
57
- await (0, module_1.UCommon)(props)
58
- .then(res => {
59
- const response = res.data;
60
- const mvurls = response?.getMVUrl?.data;
61
- if (!mvurls || typeof mvurls !== 'object' || Object.keys(mvurls).length === 0) {
62
- ctx.status = 502;
63
- ctx.body = {
64
- response: {
65
- data: null,
66
- error: 'Failed to get MV URL data'
67
- }
68
- };
69
- return;
67
+ const response = await (0, module_1.UCommon)(props);
68
+ const mvurls = response.data?.getMVUrl?.data;
69
+ if (!mvurls || typeof mvurls !== 'object' || Object.keys(mvurls).length === 0) {
70
+ (0, util_1.setApiResponse)(ctx, {
71
+ status: 502,
72
+ body: {
73
+ response: {
74
+ data: null,
75
+ error: 'Failed to get MV URL data'
76
+ }
70
77
  }
71
- const mvurlskey = Object.keys(mvurls)[0];
72
- const mp4_urls = mvurls[mvurlskey]?.mp4?.map((item) => item.freeflow_url) || [];
73
- const hls_urls = mvurls[mvurlskey]?.hls?.map((item) => item.freeflow_url) || [];
74
- const urls = [...mp4_urls, ...hls_urls];
75
- let play_urls = [];
76
- let playLists = {};
77
- if (urls.length) {
78
- urls.forEach((url) => {
79
- play_urls = [...play_urls, ...url];
80
- });
81
- playLists = {
82
- f10: play_urls.filter((item) => /\.f10\.mp4/.test(item)),
83
- f20: play_urls.filter((item) => /\.f20\.mp4/.test(item)),
84
- f30: play_urls.filter((item) => /\.f30\.mp4/.test(item)),
85
- f40: play_urls.filter((item) => /\.f40\.mp4/.test(item))
86
- };
87
- }
88
- response.playLists = playLists;
89
- ctx.status = 200;
90
- ctx.body = {
91
- response
92
- };
93
- })
94
- .catch(error => {
95
- console.log('error', error);
96
78
  });
79
+ return;
97
80
  }
98
- else {
99
- ctx.status = 400;
100
- ctx.body = {
101
- response: 'vid is null'
102
- };
81
+ const mvurlskey = Object.keys(mvurls)[0];
82
+ const mp4_urls = mvurls[mvurlskey]?.mp4?.map((item) => item.freeflow_url) || [];
83
+ const hls_urls = mvurls[mvurlskey]?.hls?.map((item) => item.freeflow_url) || [];
84
+ const urls = [...mp4_urls, ...hls_urls];
85
+ let play_urls = [];
86
+ const playLists = {
87
+ f10: [],
88
+ f20: [],
89
+ f30: [],
90
+ f40: []
91
+ };
92
+ if (urls.length) {
93
+ urls.forEach((url) => {
94
+ play_urls = [...play_urls, ...url];
95
+ });
96
+ playLists.f10 = play_urls.filter((item) => /\.f10\.mp4/.test(item));
97
+ playLists.f20 = play_urls.filter((item) => /\.f20\.mp4/.test(item));
98
+ playLists.f30 = play_urls.filter((item) => /\.f30\.mp4/.test(item));
99
+ playLists.f40 = play_urls.filter((item) => /\.f40\.mp4/.test(item));
103
100
  }
104
- };
105
- exports.default = controller;
101
+ response.data.playLists = playLists;
102
+ (0, util_1.setApiResponse)(ctx, (0, apiResponse_1.customResponse)({ response: response.data }, 200));
103
+ });
104
+ exports.default = getMvPlayController;
@@ -6,44 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getPersonalRecommendController = getPersonalRecommendController;
7
7
  exports.getSimilarSongsController = getSimilarSongsController;
8
8
  const getPersonalRecommend_1 = __importDefault(require("../../module/apis/recommend/getPersonalRecommend"));
9
- /**
10
- * 获取个性化推荐
11
- */
9
+ const cookieResolver_1 = require("../../util/cookieResolver");
10
+ const apiResponse_1 = require("../../util/apiResponse");
12
11
  async function getPersonalRecommendController(ctx) {
13
- const { type = '1', cookie } = ctx.query;
14
- // 处理数组类型,取第一个值
12
+ const { type = '1' } = ctx.query;
15
13
  const rawType = Array.isArray(type) ? type[0] : type;
16
- const rawCookie = Array.isArray(cookie) ? cookie[0] : cookie;
17
- const result = await getPersonalRecommend_1.default.getPersonalRecommend(Number(rawType), rawCookie);
14
+ const { cookie } = (0, cookieResolver_1.resolveRequestCookie)(ctx);
15
+ const result = await getPersonalRecommend_1.default.getPersonalRecommend(Number(rawType), cookie);
18
16
  ctx.status = result.status;
19
17
  ctx.body = result.body;
20
18
  }
21
- /**
22
- * 获取相似歌曲
23
- */
24
19
  async function getSimilarSongsController(ctx) {
25
- const { songmid, cookie } = ctx.query;
20
+ const { songmid } = ctx.query;
26
21
  if (!songmid) {
27
- ctx.status = 400;
28
- ctx.body = {
29
- code: -1,
30
- msg: '缺少参数 songmid',
31
- data: null
32
- };
22
+ const result = (0, apiResponse_1.errorResponse)('缺少参数 songmid', 400);
23
+ ctx.status = result.status;
24
+ ctx.body = result.body;
33
25
  return;
34
26
  }
35
- // 处理数组类型,取第一个值
36
27
  const validSongmid = Array.isArray(songmid) ? songmid[0] : songmid;
37
- // 校验空字符串
38
28
  if (!validSongmid || String(validSongmid).trim() === '') {
39
- ctx.status = 400;
40
- ctx.body = {
41
- code: -1,
42
- msg: '参数 songmid 不能为空',
43
- data: null
44
- };
29
+ const result = (0, apiResponse_1.errorResponse)('参数 songmid 不能为空', 400);
30
+ ctx.status = result.status;
31
+ ctx.body = result.body;
45
32
  return;
46
33
  }
34
+ const { cookie } = (0, cookieResolver_1.resolveRequestCookie)(ctx);
47
35
  const result = await getPersonalRecommend_1.default.getSimilarSongs(String(validSongmid), cookie);
48
36
  ctx.status = result.status;
49
37
  ctx.body = result.body;
@@ -3,55 +3,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPlaylistTagsController = getPlaylistTagsController;
7
- exports.getPlaylistsByTagController = getPlaylistsByTagController;
8
- exports.getHotCommentsController = getHotCommentsController;
9
- exports.getSingerListByAreaController = getSingerListByAreaController;
6
+ exports.getSingerListByAreaController = exports.getHotCommentsController = exports.getPlaylistsByTagController = exports.getPlaylistTagsController = void 0;
10
7
  const getPlaylistTags_1 = __importDefault(require("../../module/apis/extend/getPlaylistTags"));
8
+ const util_1 = require("../util");
9
+ const apiResponse_1 = require("../../util/apiResponse");
11
10
  /**
12
11
  * 获取歌单标签列表
13
12
  */
14
- async function getPlaylistTagsController(ctx) {
13
+ const getPlaylistTagsController = (0, util_1.withErrorHandler)(async (ctx) => {
15
14
  const result = await getPlaylistTags_1.default.getPlaylistTags();
16
- ctx.status = result.status;
17
- ctx.body = result.body;
18
- }
15
+ (0, util_1.setApiResponse)(ctx, result);
16
+ });
17
+ exports.getPlaylistTagsController = getPlaylistTagsController;
19
18
  /**
20
19
  * 根据标签获取歌单列表
21
20
  */
22
- async function getPlaylistsByTagController(ctx) {
21
+ const getPlaylistsByTagController = (0, util_1.withErrorHandler)(async (ctx) => {
23
22
  const { tagId = '1', page = '0', num = '20' } = ctx.query;
24
23
  const result = await getPlaylistTags_1.default.getPlaylistsByTag(Number(tagId), Number(page), Number(num));
25
- ctx.status = result.status;
26
- ctx.body = result.body;
27
- }
24
+ (0, util_1.setApiResponse)(ctx, result);
25
+ });
26
+ exports.getPlaylistsByTagController = getPlaylistsByTagController;
28
27
  /**
29
28
  * 获取热门评论
30
29
  */
31
- async function getHotCommentsController(ctx) {
30
+ const getHotCommentsController = (0, util_1.withErrorHandler)(async (ctx) => {
32
31
  const { id, type = '1', page = '0', pagesize = '20' } = ctx.query;
33
32
  if (!id) {
34
- ctx.status = 400;
35
- ctx.body = {
36
- code: -1,
37
- msg: '缺少参数 id(资源 ID)',
38
- data: null
39
- };
33
+ (0, util_1.setApiResponse)(ctx, (0, apiResponse_1.errorResponse)('缺少参数 id(资源 ID)', 400));
40
34
  return;
41
35
  }
42
36
  const result = await getPlaylistTags_1.default.getHotComments(id, Number(type), Number(page), Number(pagesize));
43
- ctx.status = result.status;
44
- ctx.body = result.body;
45
- }
37
+ (0, util_1.setApiResponse)(ctx, result);
38
+ });
39
+ exports.getHotCommentsController = getHotCommentsController;
46
40
  /**
47
41
  * 获取歌手分类列表
48
42
  */
49
- async function getSingerListByAreaController(ctx) {
43
+ const getSingerListByAreaController = (0, util_1.withErrorHandler)(async (ctx) => {
50
44
  const { area = '-1', sex = '-1', genre = '-1', page = '1', pagesize = '80' } = ctx.query;
51
45
  const result = await getPlaylistTags_1.default.getSingerListByArea(Number(area), Number(sex), Number(genre), Number(page), Number(pagesize));
52
- ctx.status = result.status;
53
- ctx.body = result.body;
54
- }
46
+ (0, util_1.setApiResponse)(ctx, result);
47
+ });
48
+ exports.getSingerListByAreaController = getSingerListByAreaController;
55
49
  exports.default = {
56
50
  getPlaylistTags: getPlaylistTagsController,
57
51
  getPlaylistsByTag: getPlaylistsByTagController,
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- const controller = async (ctx, next) => {
4
+ const util_1 = require("../util");
5
+ const apiResponse_1 = require("../../util/apiResponse");
6
+ const getRanksController = (0, util_1.withErrorHandler)(async (ctx) => {
5
7
  const getWeekNumber = (d) => {
6
8
  d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
7
9
  const dayNum = d.getUTCDay() || 7;
@@ -36,25 +38,16 @@ const controller = async (ctx, next) => {
36
38
  }
37
39
  }
38
40
  };
39
- const params = Object.assign({
41
+ const params = {
40
42
  format: 'json',
41
43
  data: JSON.stringify(data)
42
- });
44
+ };
43
45
  const props = {
44
46
  method: 'get',
45
47
  params,
46
48
  option: {}
47
49
  };
48
- await (0, module_1.UCommon)(props)
49
- .then(res => {
50
- const response = res.data;
51
- ctx.status = 200;
52
- ctx.body = {
53
- response
54
- };
55
- })
56
- .catch(error => {
57
- console.log('error', error);
58
- });
59
- };
60
- exports.default = controller;
50
+ const response = await (0, module_1.UCommon)(props);
51
+ (0, util_1.setApiResponse)(ctx, (0, apiResponse_1.customResponse)({ response: response.data }, 200));
52
+ });
53
+ exports.default = getRanksController;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- const controller = async (ctx, next) => {
4
+ const util_1 = require("../util");
5
+ const apiResponse_1 = require("../../util/apiResponse");
6
+ const getSingerAlbumController = (0, util_1.withErrorHandler)(async (ctx) => {
5
7
  const singermid = ctx.query.singermid;
6
8
  const num = +ctx.query.limit || 5;
7
9
  const begin = +ctx.query.page || 0;
@@ -21,34 +23,26 @@ const controller = async (ctx, next) => {
21
23
  module: 'music.musichallAlbum.AlbumListServer'
22
24
  }
23
25
  };
24
- const params = Object.assign({
26
+ const params = {
25
27
  format: 'json',
26
28
  singermid,
27
29
  data: JSON.stringify(data)
28
- });
30
+ };
29
31
  const props = {
30
32
  method: 'get',
31
33
  params,
32
34
  option: {}
33
35
  };
34
- if (singermid) {
35
- await (0, module_1.UCommon)(props)
36
- .then(res => {
37
- const response = res.data;
38
- ctx.status = 200;
39
- ctx.body = {
40
- response
41
- };
42
- })
43
- .catch(error => {
44
- console.log('error', error);
36
+ if (!singermid) {
37
+ (0, util_1.setApiResponse)(ctx, {
38
+ status: 400,
39
+ body: {
40
+ response: 'no singermid'
41
+ }
45
42
  });
43
+ return;
46
44
  }
47
- else {
48
- ctx.status = 400;
49
- ctx.body = {
50
- response: 'no singermid'
51
- };
52
- }
53
- };
54
- exports.default = controller;
45
+ const response = await (0, module_1.UCommon)(props);
46
+ (0, util_1.setApiResponse)(ctx, (0, apiResponse_1.customResponse)({ response: response.data }, 200));
47
+ });
48
+ exports.default = getSingerAlbumController;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const module_1 = require("../../module");
4
- const controller = async (ctx, next) => {
4
+ const util_1 = require("../util");
5
+ const apiResponse_1 = require("../../util/apiResponse");
6
+ const getSingerHotsongController = (0, util_1.withErrorHandler)(async (ctx) => {
5
7
  const singermid = ctx.query.singermid;
6
8
  const num = +ctx.query.limit || 5;
7
9
  const page = +ctx.query.page || 0;
@@ -21,34 +23,26 @@ const controller = async (ctx, next) => {
21
23
  module: 'music.web_singer_info_svr'
22
24
  }
23
25
  };
24
- const params = Object.assign({
26
+ const params = {
25
27
  format: 'json',
26
28
  singermid,
27
29
  data: JSON.stringify(data)
28
- });
30
+ };
29
31
  const props = {
30
32
  method: 'get',
31
33
  params,
32
34
  option: {}
33
35
  };
34
- if (singermid) {
35
- await (0, module_1.UCommon)(props)
36
- .then(res => {
37
- const response = res.data;
38
- ctx.status = 200;
39
- ctx.body = {
40
- response
41
- };
42
- })
43
- .catch(error => {
44
- console.log('error', error);
36
+ if (!singermid) {
37
+ (0, util_1.setApiResponse)(ctx, {
38
+ status: 400,
39
+ body: {
40
+ response: 'no singermid'
41
+ }
45
42
  });
43
+ return;
46
44
  }
47
- else {
48
- ctx.status = 400;
49
- ctx.body = {
50
- response: 'no singermid'
51
- };
52
- }
53
- };
54
- exports.default = controller;
45
+ const response = await (0, module_1.UCommon)(props);
46
+ (0, util_1.setApiResponse)(ctx, (0, apiResponse_1.customResponse)({ response: response.data }, 200));
47
+ });
48
+ exports.default = getSingerHotsongController;