From c3a190fda9d4db36668634baa6889d37c80ec6e0 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 13 Aug 2022 15:46:56 -0500 Subject: [PATCH] fix(route): douyin live (#10460) --- lib/v2/douyin/live.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/v2/douyin/live.js b/lib/v2/douyin/live.js index b3a139d7a..af4f25f4b 100644 --- a/lib/v2/douyin/live.js +++ b/lib/v2/douyin/live.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { await page.goto(pageUrl, { waitUntil: 'domcontentloaded', }); - const data = await page.evaluate(() => renderData); + const data = JSON.parse(decodeURIComponent(await page.evaluate(() => document.querySelector('#RENDER_DATA').innerText))); browser.close(); return data; @@ -30,11 +30,11 @@ module.exports = async (ctx) => { false ); - if (renderData.routeInitialProps.status_code !== '0') { - throw `Status code ${renderData.routeInitialProps.status_code}: ${renderData.routeInitialProps.error.title}`; + if (renderData[Object.keys(renderData).find((k) => renderData[k].status_code)].status_code !== '0') { + throw `Status code ${renderData[Object.keys(renderData).find((k) => renderData[k].status_code)].status_code}`; } - const roomInfo = renderData.initialState.roomStore.roomInfo; + const roomInfo = renderData.app.initialState.roomStore.roomInfo; const nickname = roomInfo.anchor.nickname; const userAvatar = roomInfo.anchor.avatar_thumb.url_list[0];