From f236d54d2d74719882d31edf87e6fa1c9bef4ccd Mon Sep 17 00:00:00 2001 From: dzx-dzx Date: Wed, 13 Nov 2024 13:51:59 +0800 Subject: [PATCH 1/3] feat(route/caixin): Add support for photos channel. Example: https://photos.caixin.com/2024-11-02/102252287.html --- lib/routes/caixin/utils-fulltext.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/caixin/utils-fulltext.ts b/lib/routes/caixin/utils-fulltext.ts index 1a8289049dda18..b358cc6777f27e 100644 --- a/lib/routes/caixin/utils-fulltext.ts +++ b/lib/routes/caixin/utils-fulltext.ts @@ -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 String.prototype.concat(content, pictureList ? pictureList.map((e) => `${e.desc}
${e.desc}
`).join('') : ''); } From 362edc032936d3a4d222f50aab8b1f730d2857e2 Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:59:49 +0800 Subject: [PATCH 2/3] Update utils-fulltext.ts --- lib/routes/caixin/utils-fulltext.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/caixin/utils-fulltext.ts b/lib/routes/caixin/utils-fulltext.ts index b358cc6777f27e..c866784508e529 100644 --- a/lib/routes/caixin/utils-fulltext.ts +++ b/lib/routes/caixin/utils-fulltext.ts @@ -46,6 +46,6 @@ export async function getFulltext(url: string) { }, }); - const { content, pictureList } = JSON.parse(res.data.match(/resetContentInfo\((.*)\)/)[1]); - return String.prototype.concat(content, pictureList ? pictureList.map((e) => `${e.desc}
${e.desc}
`).join('') : ''); + const { content = '', pictureList } = JSON.parse(res.data.match(/resetContentInfo\((.*)\)/)[1]); + return content + (pictureList ? pictureList.map((e) => `${e.desc}
${e.desc}
`).join('') : ''); } From b0fadae5079f78525f4763eed913e3880f2f41a7 Mon Sep 17 00:00:00 2001 From: dzx-dzx Date: Wed, 13 Nov 2024 16:06:39 +0800 Subject: [PATCH 3/3] . --- lib/routes/caixin/latest.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/routes/caixin/latest.ts b/lib/routes/caixin/latest.ts index b6b23a9b27cb0e..da585b75c2e293 100644 --- a/lib/routes/caixin/latest.ts +++ b/lib/routes/caixin/latest.ts @@ -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}`;