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 noteUrl = url + '/' + n.note_id;
return cache.tryGet(
noteUrl,
async () => {
const notePage = await browser.newPage();
await setPageFilter(notePage);
return cache.tryGet(noteUrl, async () => {
const notePage = await browser.newPage();
await setPageFilter(notePage);
logger.debug(`Requesting ${noteUrl}`);
await notePage.goto(noteUrl);
logger.debug(`Requesting ${noteUrl}`);
await notePage.goto(noteUrl);
let feed = {};
try {
feed = await notePage.evaluate(() => window.__INITIAL_STATE__);
let feed = {};
try {
feed = await notePage.evaluate(() => window.__INITIAL_STATE__);
// Sometimes the page is not server-side rendered
if (typeof feed?.note?.note === 'undefined' || JSON.stringify(feed?.note?.note) === '{}') {
const res = await notePage.waitForResponse((res) => {
const req = res.request();
return req.url().includes('/api/sns/web/v1/feed') && req.method() === 'POST';
});
// Sometimes the page is not server-side rendered
if (typeof feed?.note?.note === 'undefined' || JSON.stringify(feed?.note?.note) === '{}') {
const res = await notePage.waitForResponse((res) => {
const req = res.request();
return req.url().includes('/api/sns/web/v1/feed') && req.method() === 'POST';
});
const json = await res.json();
const note_card = json.data.items[0].note_card;
feed.note.note = {
title: note_card.title,
noteId: note_card.id,
desc: note_card.desc,
tagList: note_card.tag_list,
imageList: note_card.image_list,
user: note_card.user,
time: note_card.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}`);
const json = await res.json();
const note_card = json.data.items[0].note_card;
feed.note.note = {
title: note_card.title,
noteId: note_card.id,
desc: note_card.desc,
tagList: note_card.tag_list,
imageList: note_card.image_list,
user: note_card.user,
time: note_card.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}`);
}
});
});
user = otherInfo.data.basic_info;