mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 10:15:23 +08:00
feat(route): add World Health Organization News (#8022)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -562,6 +562,18 @@ Provides all of the Thrillist articles with the specified tag.
|
|||||||
|
|
||||||
## World Health Organization | WHO
|
## World Health Organization | WHO
|
||||||
|
|
||||||
|
### News
|
||||||
|
|
||||||
|
<RouteEn author="nczitzk" example="/who/news" path="/who/news/:language?" :paramsDesc="['Language, see below, English by default']">
|
||||||
|
|
||||||
|
Language
|
||||||
|
|
||||||
|
| English | العربية | 中文 | Français | Русский | Español | Português |
|
||||||
|
| ------- | ------- | ---- | -------- | ------- | ------- | --------- |
|
||||||
|
| en | ar | zh | fr | ru | es | pt |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
### Newsroom
|
### Newsroom
|
||||||
|
|
||||||
<RouteEn author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
|
<RouteEn author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
|
||||||
|
|||||||
@@ -2294,6 +2294,18 @@ column 为 third 时可选的 category:
|
|||||||
|
|
||||||
## 世界卫生组织 WHO
|
## 世界卫生组织 WHO
|
||||||
|
|
||||||
|
### 新闻稿
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/who/news" path="/who/news/:language?" :paramsDesc="['语言,见下表,默认为英语']">
|
||||||
|
|
||||||
|
语言
|
||||||
|
|
||||||
|
| English | العربية | 中文 | Français | Русский | Español | Português |
|
||||||
|
| ------- | ------- | ---- | -------- | ------- | ------- | --------- |
|
||||||
|
| en | ar | zh | fr | ru | es | pt |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
### 媒体中心
|
### 媒体中心
|
||||||
|
|
||||||
<Route author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
|
<Route author="LogicJake" example="/who/news-room/feature-stories" path="/who/news-room/:type" :paramsDesc="['类别,可在 URL 中找到']"/>
|
||||||
|
|||||||
@@ -1692,6 +1692,7 @@ router.get('/nintendo/system-update', lazyloadRouteHandler('./routes/nintendo/sy
|
|||||||
|
|
||||||
// 世界卫生组织
|
// 世界卫生组织
|
||||||
router.get('/who/news-room/:type', lazyloadRouteHandler('./routes/who/news-room'));
|
router.get('/who/news-room/:type', lazyloadRouteHandler('./routes/who/news-room'));
|
||||||
|
router.get('/who/news/:language?', require('./routes/who/news'));
|
||||||
|
|
||||||
// 福利资源-met.red
|
// 福利资源-met.red
|
||||||
router.get('/metred/fuli', lazyloadRouteHandler('./routes/metred/fuli'));
|
router.get('/metred/fuli', lazyloadRouteHandler('./routes/metred/fuli'));
|
||||||
|
|||||||
43
lib/routes/who/news.js
Normal file
43
lib/routes/who/news.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const language = ctx.params.language || 'en';
|
||||||
|
|
||||||
|
const rootUrl = 'https://www.who.int';
|
||||||
|
const currentUrl = `${rootUrl}/${language === 'en' ? '' : `${language}/`}news`;
|
||||||
|
const apiUrl = `${rootUrl}/api/news/newsitems?sf_culture=${language}&$orderby=PublicationDateAndTime%20desc&$select=Title,PublicationDateAndTime,ItemDefaultUrl`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: apiUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const list = response.data.value.map((item) => ({
|
||||||
|
title: item.Title,
|
||||||
|
link: `${currentUrl}/item/${item.ItemDefaultUrl}`,
|
||||||
|
pubDate: parseDate(item.PublicationDateAndTime),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(
|
||||||
|
async (item) =>
|
||||||
|
await ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
|
||||||
|
item.description = detailResponse.data.match(/"description":"(.*)","datePublished"/)[1];
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'News - WHO',
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user