From 82a78e23a3d0f641f132db0874c687a9ffc036f7 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Sun, 9 Oct 2022 23:18:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E4=BA=91=E5=90=AC=E4=B8=93?= =?UTF-8?q?=E8=BE=91=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0=E8=8A=82=E7=9B=AE?= =?UTF-8?q?=20(#11028)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/radio/album.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/v2/radio/album.js b/lib/v2/radio/album.js index f6aec28a8..8212df777 100644 --- a/lib/v2/radio/album.js +++ b/lib/v2/radio/album.js @@ -8,9 +8,7 @@ module.exports = async (ctx) => { const KEY = 'f0fc4c668392f9f9a447e48584c214ee'; const id = ctx.params.id; - const size = ctx.query.limit ?? '100'; - - const params = `albumId=${id}&pageNo=0&pageSize=${size}`; + const size = ctx.query.limit ? parseInt(ctx.query.limit) : 100; const rootUrl = 'https://www.radio.cn'; const apiRootUrl = 'https://ytmsout.radio.cn'; @@ -18,7 +16,6 @@ module.exports = async (ctx) => { const iconUrl = `${rootUrl}/pc-portal/image/icon_32.jpg`; const currentUrl = `${rootUrl}/pc-portal/sanji/detail.html?columnId=${id}`; - const apiUrl = `${apiRootUrl}/web/appSingle/pageByAlbum?${params}`; const detailUrl = `${detailRootUrl}/ytsrv/srv/wifimusicbox/demand/detail`; const detailResponse = await got({ @@ -26,7 +23,7 @@ module.exports = async (ctx) => { url: detailUrl, form: { pageIndex: '0', - sortType: '1', + sortType: '2', mobileId: '', providerCode: '25010', pid: id, @@ -44,6 +41,19 @@ module.exports = async (ctx) => { const data = detailResponse.data; + const count = data.count; + + let pageNo = 1, + pageSize = count - size; + + if (pageSize <= 0) { + pageNo = 0; + pageSize = count; + } + + const params = `albumId=${id}&pageNo=${pageNo}&pageSize=${pageSize}`; + const apiUrl = `${apiRootUrl}/web/appSingle/pageByAlbum?${params}`; + const timestamp = new Date().getTime(); const sign = CryptoJS.MD5(`${params}×tamp=${timestamp}&key=${KEY}`).toString().toUpperCase();