style: auto format

This commit is contained in:
github-actions[bot]
2023-05-15 14:17:07 +00:00
parent d0d3b6b870
commit 9bdba060c7

View File

@@ -114,52 +114,49 @@ const getNotes = (url, cache) =>
const notesPromise = userPosted.data.notes.map((n) => { const notesPromise = userPosted.data.notes.map((n) => {
const noteUrl = url + '/' + n.note_id; const noteUrl = url + '/' + n.note_id;
return cache.tryGet( return cache.tryGet(noteUrl, async () => {
noteUrl, const notePage = await browser.newPage();
async () => { await setPageFilter(notePage);
const notePage = await browser.newPage();
await setPageFilter(notePage);
logger.debug(`Requesting ${noteUrl}`); logger.debug(`Requesting ${noteUrl}`);
await notePage.goto(noteUrl); await notePage.goto(noteUrl);
let feed = {}; let feed = {};
try { try {
feed = await notePage.evaluate(() => window.__INITIAL_STATE__); feed = await notePage.evaluate(() => window.__INITIAL_STATE__);
// Sometimes the page is not server-side rendered // Sometimes the page is not server-side rendered
if (typeof feed?.note?.note === 'undefined' || JSON.stringify(feed?.note?.note) === '{}') { if (typeof feed?.note?.note === 'undefined' || JSON.stringify(feed?.note?.note) === '{}') {
const res = await notePage.waitForResponse((res) => { const res = await notePage.waitForResponse((res) => {
const req = res.request(); const req = res.request();
return req.url().includes('/api/sns/web/v1/feed') && req.method() === 'POST'; return req.url().includes('/api/sns/web/v1/feed') && req.method() === 'POST';
}); });
const json = await res.json(); const json = await res.json();
const note_card = json.data.items[0].note_card; const note_card = json.data.items[0].note_card;
feed.note.note = { feed.note.note = {
title: note_card.title, title: note_card.title,
noteId: note_card.id, noteId: note_card.id,
desc: note_card.desc, desc: note_card.desc,
tagList: note_card.tag_list, tagList: note_card.tag_list,
imageList: note_card.image_list, imageList: note_card.image_list,
user: note_card.user, user: note_card.user,
time: note_card.time, time: note_card.time,
lastUpdateTime: note_card.last_update_time, lastUpdateTime: note_card.last_update_time,
}; };
}
} catch (e) {
throw Error(`Could not get note ${n.note_id}\n${e}`);
}
await notePage.close();
if (typeof feed?.note?.note !== 'undefined' && JSON.stringify(feed?.note?.note) !== '{}') {
return feed.note.note;
} else {
throw Error(`Could not get note ${n.note_id}`);
} }
} catch (e) {
throw Error(`Could not get note ${n.note_id}\n${e}`);
} }
);
await notePage.close();
if (typeof feed?.note?.note !== 'undefined' && JSON.stringify(feed?.note?.note) !== '{}') {
return feed.note.note;
} else {
throw Error(`Could not get note ${n.note_id}`);
}
});
}); });
user = otherInfo.data.basic_info; user = otherInfo.data.basic_info;