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();