Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route/caixin): Add support for photos channel. Example: https://photos.caixin.com/2024-11-02/102252287.html #17566

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/routes/caixin/latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ async function handler(ctx) {
// desc
const desc = await parseArticle(item);

item.description = ctx.req.query('fulltext') === 'true' ? ((await getFulltext(item.link)) ?? desc.description) : desc.description;
if (ctx.req.query('fulltext') === 'true') {
const authorizedFullText = await getFulltext(item.link);
item.description = authorizedFullText === '' ? desc.description : authorizedFullText;
} else {
item.description = desc.description;
}
// prevent cache coliision with /caixin/article and /caixin/:column/:category
// since those have podcasts
item.guid = `caixin:latest:${item.link}`;
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/caixin/utils-fulltext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ export async function getFulltext(url: string) {
},
});

const { content } = JSON.parse(res.data.match(/resetContentInfo\((.*)\)/)[1]);
return content;
const { content = '', pictureList } = JSON.parse(res.data.match(/resetContentInfo\((.*)\)/)[1]);
return content + (pictureList ? pictureList.map((e) => `<img src="${e.url}" id="picture_${e.id}" alt="${e.desc}"><dl><dt>${e.desc}</dt></dl>`).join('') : '');
}