fix(route): douyin live (#10460)

This commit is contained in:
Tony 2022-08-13 15:46:56 -05:00 committed by GitHub
parent fdbb6fa709
commit c3a190fda9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -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];