mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
style: auto format
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user