Skip to content

Commit

Permalink
Merge pull request #332 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Dec 28, 2024
2 parents 5f8876e + 6233163 commit d8c2c58
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
7 changes: 4 additions & 3 deletions lib/routes/chinacdc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const handler = async (ctx: Context): Promise<Data> => {
return {
title,
description,
link: item.link,
pubDate: parseDate($$('span.fb em').text()),
content: {
html: description,
Expand Down Expand Up @@ -122,7 +123,7 @@ export const route: Route = {
handler,
example: '/chinacdc/zxyw',
parameters: {
category: '分类,默认为 `zxyw`,即中心要闻,可在对应分类页 URL 中找到, Category, `zxyw`,即中心要闻 by default',
category: '分类,默认为 `zxyw`,即中心要闻,可在对应分类页 URL 中找到Category, `zxyw`,即中心要闻 by default',
},
description: `:::tip
若订阅 [中心要闻](https://www.chinacdc.cn/zxyw/),网址为 \`https://www.chinacdc.cn/zxyw/\`,请截取 \`https://www.chinacdc.cn/\` 到末尾 \`/\` 的部分 \`zxyw\` 作为 \`category\` 参数填入,此时目标路由为 [\`/chinacdc/zxyw\`](https://rsshub.app/chinacdc/zxyw)。
Expand Down Expand Up @@ -169,7 +170,7 @@ export const route: Route = {
#### [全球公卫](https://www.chinacdc.cn/qqgw/)
| [合作伙伴](https://www.chinacdc.cn/qqgw/hzhb/) | [世界卫生组织合作中心和参比实验室](https://www.chinacdc.cn/qqgw/wszz/) | [国际交流(港澳台交流)](https://www.chinacdc.cn/qqgw/gjjl/) | [公共卫生援外与合作](https://www.chinacdc.cn/qqgw/ggws/) |
| [合作伙伴](https://www.chinacdc.cn/qqgw/hzhb/) | [世界卫生组织合作中心和参比实验室](https://www.chinacdc.cn/qqgw/wszz/) | [国际交流 (港澳台交流)](https://www.chinacdc.cn/qqgw/gjjl/) | [公共卫生援外与合作](https://www.chinacdc.cn/qqgw/ggws/) |
| -------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------- | -------------------------------------------------------- |
| [qqgw/hzhb](https://rsshub.app/chinacdc/qqgw/hzhb) | [qqgw/wszz](https://rsshub.app/chinacdc/qqgw/wszz) | [qqgw/gjjl](https://rsshub.app/chinacdc/qqgw/gjjl) | [qqgw/ggws](https://rsshub.app/chinacdc/qqgw/ggws) |
Expand Down Expand Up @@ -371,7 +372,7 @@ export const route: Route = {
target: '/qqgw/wszz',
},
{
title: '全球公卫 - 国际交流(港澳台交流)',
title: '全球公卫 - 国际交流 (港澳台交流)',
source: ['www.chinacdc.cn/qqgw/gjjl/'],
target: '/qqgw/gjjl',
},
Expand Down
36 changes: 29 additions & 7 deletions lib/routes/msn/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
import cache from '@/utils/cache';
import { load } from 'cheerio';

const apiKey = '0QfOX3Vn51YCzitbLaRkTTBadtWpgTN8NZLW0C1SEM';
Expand Down Expand Up @@ -44,13 +45,34 @@ export const route: Route = {
const requestMuid = parsedSettings.fd_muid;

const jsonData = await ofetch(`https://assets.msn.com/service/news/feed/pages/providerfullpage?market=${market}&query=newest&CommunityProfileId=${truncatedId}&apikey=${apiKey}&user=m-${requestMuid}`);
const items = jsonData.sections[0].cards.map((card) => ({
title: card.title,
link: card.url,
description: card.abstract,
pubDate: parseDate(card.publishedDateTime),
category: [card.category],
}));
const items = await Promise.all(
jsonData.sections[0].cards.map(async (card) => {
let articleContentHtml = '';

const articleUrl = card.url;
const parsedArticleUrl = URL.parse(articleUrl);
let articleId = parsedArticleUrl?.pathname.split('/').pop();
if (articleId?.startsWith('ar-')) {
articleId = articleId.substring(3);
const fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => {
const articleData = await ofetch(`https://assets.msn.com/content/view/v2/Detail/${market}/${articleId}`);
return articleData.body;
})) as string; // cache article content for 3 months
articleContentHtml = fetchedArticleContentHtml;
}

return {
title: card.title,
link: articleUrl,
description: card.abstract,
content: {
html: articleContentHtml,
},
pubDate: parseDate(card.publishedDateTime),
category: [card.category],
};
})
);

const channelLink = `https://www.msn.com/${market}/channel/source/${name}/${id}`;
return {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/oschina/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function handler(ctx) {
return {
title: author + '的博客',
description: $('.user-text .user-signature').text(),
link: `https://my.oschina.net/${id ?? uid}`,
link: `https://my.oschina.net/u/${id ?? uid}`,
item: resultItem,
};
}

0 comments on commit d8c2c58

Please sign in to comment.