fix(route): 国家气候中心最新监测 (#15490)
* fix(route): 国家气候中心最新监测 * update cmdp.ts * update namespace.ts
This commit is contained in:
parent
9b09c12d9b
commit
bf11a10f6d
|
|
@ -9,16 +9,9 @@ import { art } from '@/utils/render';
|
|||
import path from 'node:path';
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/cmdp/image/:id{.+}?',
|
||||
name: 'Unknown',
|
||||
maintainers: [],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const id = ctx.req.param('id');
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 50;
|
||||
export const handler = async (ctx) => {
|
||||
const { id = 'RPJQWQYZ' } = ctx.req.param();
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
||||
|
||||
const ids = id?.split(/\//) ?? [];
|
||||
const titles = [];
|
||||
|
|
@ -33,6 +26,7 @@ async function handler(ctx) {
|
|||
const $ = load(iconv.decode(response, 'gbk'));
|
||||
|
||||
const author = '国家气候中心';
|
||||
const language = 'zh';
|
||||
|
||||
const items = $('ul.img-con-new-con li img[id]')
|
||||
.toArray()
|
||||
|
|
@ -43,9 +37,9 @@ async function handler(ctx) {
|
|||
|
||||
const id = item.prop('id');
|
||||
const title = $(`li[data-id="${id}"]`).text() || undefined;
|
||||
const src = new URL(item.prop('src'), currentUrl).href;
|
||||
const image = new URL(item.prop('src'), currentUrl).href;
|
||||
const date =
|
||||
src
|
||||
image
|
||||
.match(/_(\d{4})(\d{2})(\d{2})_/)
|
||||
?.slice(1, 4)
|
||||
.join('-') ?? new Date().toISOString().slice(0, 10);
|
||||
|
|
@ -54,39 +48,302 @@ async function handler(ctx) {
|
|||
titles.push(title);
|
||||
}
|
||||
|
||||
const description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
images: image
|
||||
? [
|
||||
{
|
||||
src: image,
|
||||
alt: `${title} ${date}`,
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
});
|
||||
const guid = `ncc-cma#${id}#${date}`;
|
||||
|
||||
return {
|
||||
title: `${title} ${date}`,
|
||||
link: currentUrl,
|
||||
description: art(path.join(__dirname, 'templates/description.art'), {
|
||||
image: {
|
||||
src,
|
||||
alt: `${title} ${date}`,
|
||||
},
|
||||
}),
|
||||
author,
|
||||
category: [title],
|
||||
guid: `ncc-cma#${id}#${date}`,
|
||||
description,
|
||||
pubDate: parseDate(date),
|
||||
enclosure_url: src,
|
||||
enclosure_type: `image/${src.split(/\./).pop()}`,
|
||||
link: currentUrl,
|
||||
category: [title],
|
||||
author,
|
||||
guid,
|
||||
id: guid,
|
||||
content: {
|
||||
html: description,
|
||||
text: description,
|
||||
},
|
||||
image,
|
||||
banner: image,
|
||||
language,
|
||||
enclosure_url: image,
|
||||
enclosure_type: `image/${image.split(/\./).pop()}`,
|
||||
enclosure_title: `${title} ${date}`,
|
||||
};
|
||||
});
|
||||
|
||||
const subtitle = $('h1').last().text();
|
||||
const image = $('img.logo').prop('src');
|
||||
const icon = new URL('favicon.ico', rootUrl).href;
|
||||
|
||||
return {
|
||||
item: items,
|
||||
title: `${author} - ${subtitle}${titles.length === 0 ? '' : ` - ${titles.join('|')}`}`,
|
||||
link: currentUrl,
|
||||
description: $('title').text(),
|
||||
language: 'zh',
|
||||
image,
|
||||
icon,
|
||||
logo: icon,
|
||||
subtitle,
|
||||
author,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
image,
|
||||
author,
|
||||
language,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/cmdp/image/:id{.+}?',
|
||||
name: '最新监测',
|
||||
url: 'cmdp.ncc-cma.net',
|
||||
maintainers: ['nczitzk'],
|
||||
handler,
|
||||
example: '/ncc-cma/cmdp/image/RPJQWQYZ',
|
||||
parameters: { category: '图片,默认为 RPJQWQYZ,即日平均气温距平,可在对应列表项 data-id 属性中找到' },
|
||||
description: `:::tip
|
||||
若订阅日平均气温距平,将其 data-id \`RPJQWQYZ\` 作为参数填入,此时路由为 [\`/ncc-cma/cmdp/image/RPJQWQYZ\`](https://rsshub.app/ncc-cma/cmdp/image/RPJQWQYZ)。
|
||||
|
||||
若同时订阅日平均气温距平、近5天平均气温距和近10天平均气温距平,将其 data-id \`RPJQWQYZ\`、\`ZJ5TPJQWJP\` 和 \`ZJ10TQWJP\` 作为参数填入,此时路由为 [\`/ncc-cma/cmdp/image/RPJQWQYZ/ZJ5TPJQWJP/ZJ10TQWJP\`](https://rsshub.app/ncc-cma/cmdp/image/RPJQWQYZ/ZJ5TPJQWJP/ZJ10TQWJP)。
|
||||
:::
|
||||
|
||||
| 日平均气温距平 | 近5天平均气温距平 | 近10天平均气温距平 | 近20天平均气温距平 | 近30天平均气温距平 |
|
||||
| ----------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- |
|
||||
| [RPJQWQYZ](https://rsshub.app/ncc-cma/cmdp/image/RPJQWQYZ) | [ZJ5TPJQWJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ5TPJQWJP) | [ZJ10TQWJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ10TQWJP) | [ZJ20TQWJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ20TQWJP) | [ZJ30TQWJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ30TQWJP) |
|
||||
|
||||
| 本月以来气温距平 | 本季以来气温距平 | 本年以来气温距平 |
|
||||
| ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
|
||||
| [BYYLQWJP](https://rsshub.app/ncc-cma/cmdp/image/BYYLQWJP) | [BJYLQWJP](https://rsshub.app/ncc-cma/cmdp/image/BJYLQWJP) | [BNYLQWJP](https://rsshub.app/ncc-cma/cmdp/image/BNYLQWJP) |
|
||||
|
||||
| 日降水量分布 | 近5天降水量 | 近10天降水量 | 近20天降水量 | 近30天降水量 |
|
||||
| ----------------------------------------------------------------------- | --------------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
|
||||
| [QGRJSLFBT0808S](https://rsshub.app/ncc-cma/cmdp/image/QGRJSLFBT0808S) | [ZJ5TJSLFBT](https://rsshub.app/ncc-cma/cmdp/image/ZJ5TJSLFBT) | [ZJ10TJSL](https://rsshub.app/ncc-cma/cmdp/image/ZJ10TJSL) | [ZJ20TJSL](https://rsshub.app/ncc-cma/cmdp/image/ZJ20TJSL) | [ZJ30TJSL](https://rsshub.app/ncc-cma/cmdp/image/ZJ30TJSL) |
|
||||
|
||||
| 本月以来降水量 | 本季以来降水量 | 近10天降水量距平百分率 | 近20天降水量距平百分率 | 近30天降水量距平百分率 |
|
||||
| --------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- |
|
||||
| [BYYLJSL](https://rsshub.app/ncc-cma/cmdp/image/BYYLJSL) | [BJYLJSL](https://rsshub.app/ncc-cma/cmdp/image/BJYLJSL) | [ZJ10TJSLJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ10TJSLJP) | [ZJ20TJSLJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ20TJSLJP) | [ZJ30TJSLJP](https://rsshub.app/ncc-cma/cmdp/image/ZJ30TJSLJP) |
|
||||
|
||||
| 本月以来降水量距平百分率 | 本季以来降水量距平百分率 | 本年以来降水量距平百分率 |
|
||||
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------- |
|
||||
| [BYYLJSLJPZYQHZ](https://rsshub.app/ncc-cma/cmdp/image/BYYLJSLJPZYQHZ) | [BJYLJSLJPZJQHZ](https://rsshub.app/ncc-cma/cmdp/image/BJYLJSLJPZJQHZ) | [BNYLJSLJP](https://rsshub.app/ncc-cma/cmdp/image/BNYLJSLJP) |
|
||||
|
||||
| 气温距平(最近10天) | 气温距平(最近20天) | 气温距平(最近30天) | 气温距平(最近90天) | 最低气温距平(最近30天) |
|
||||
| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------ |
|
||||
| [glbtmeana10\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmeana10_) | [glbtmeana20\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmeana20_) | [glbtmeana30\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmeana30_) | [glbtmeana90\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmeana90_) | [glbtmina30\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmina30_) |
|
||||
|
||||
| 最低气温距平(最近90天) | 最高气温距平(最近30天) | 最高气温距平(最近90天) |
|
||||
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
||||
| [glbtmina90\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmina90_) | [glbtmaxa30\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmaxa30_) | [glbtmaxa90\_](https://rsshub.app/ncc-cma/cmdp/image/glbtmaxa90_) |
|
||||
|
||||
| 降水量(最近10天) | 降水量(最近20天) | 降水量(最近30天) | 降水量(最近90天) | 降水距平百分率(最近10天) |
|
||||
| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------ |
|
||||
| [glbrain10\_](https://rsshub.app/ncc-cma/cmdp/image/glbrain10_) | [glbrain20\_](https://rsshub.app/ncc-cma/cmdp/image/glbrain20_) | [glbrain30\_](https://rsshub.app/ncc-cma/cmdp/image/glbrain30_) | [glbrain90\_](https://rsshub.app/ncc-cma/cmdp/image/glbrain90_) | [glbraina10\_](https://rsshub.app/ncc-cma/cmdp/image/glbraina10_) |
|
||||
|
||||
| 降水距平百分率(最近20天) | 降水距平百分率(最近30天) | 降水距平百分率(最近90天) |
|
||||
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
||||
| [glbraina20\_](https://rsshub.app/ncc-cma/cmdp/image/glbraina20_) | [glbraina30\_](https://rsshub.app/ncc-cma/cmdp/image/glbraina30_) | [glbraina90\_](https://rsshub.app/ncc-cma/cmdp/image/glbraina90_) |
|
||||
|
||||
`,
|
||||
categories: ['forecast'],
|
||||
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportRadar: true,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
title: '日平均气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/RPJQWQYZ',
|
||||
},
|
||||
{
|
||||
title: '近5天平均气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ5TPJQWJP',
|
||||
},
|
||||
{
|
||||
title: '近10天平均气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ10TQWJP',
|
||||
},
|
||||
{
|
||||
title: '近20天平均气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ20TQWJP',
|
||||
},
|
||||
{
|
||||
title: '近30天平均气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ30TQWJP',
|
||||
},
|
||||
{
|
||||
title: '本月以来气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BYYLQWJP',
|
||||
},
|
||||
{
|
||||
title: '本季以来气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BJYLQWJP',
|
||||
},
|
||||
{
|
||||
title: '本年以来气温距平',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BNYLQWJP',
|
||||
},
|
||||
{
|
||||
title: '日降水量分布',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/QGRJSLFBT0808S',
|
||||
},
|
||||
{
|
||||
title: '近5天降水量',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ5TJSLFBT',
|
||||
},
|
||||
{
|
||||
title: '近10天降水量',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ10TJSL',
|
||||
},
|
||||
{
|
||||
title: '近20天降水量',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ20TJSL',
|
||||
},
|
||||
{
|
||||
title: '近30天降水量',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ30TJSL',
|
||||
},
|
||||
{
|
||||
title: '本月以来降水量',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/ncc-cma/cmdp/image/BYYLJSL',
|
||||
},
|
||||
{
|
||||
title: '本季以来降水量',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BJYLJSL',
|
||||
},
|
||||
{
|
||||
title: '近10天降水量距平百分率',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ10TJSLJP',
|
||||
},
|
||||
{
|
||||
title: '近20天降水量距平百分率',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ20TJSLJP',
|
||||
},
|
||||
{
|
||||
title: '近30天降水量距平百分率',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/ZJ30TJSLJP',
|
||||
},
|
||||
{
|
||||
title: '本月以来降水量距平百分率',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BYYLJSLJPZYQHZ',
|
||||
},
|
||||
{
|
||||
title: '本季以来降水量距平百分率',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BJYLJSLJPZJQHZ',
|
||||
},
|
||||
{
|
||||
title: '本年以来降水量距平百分率',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/BNYLJSLJP',
|
||||
},
|
||||
{
|
||||
title: '气温距平(最近10天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmeana10_',
|
||||
},
|
||||
{
|
||||
title: '气温距平(最近20天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmeana20_',
|
||||
},
|
||||
{
|
||||
title: '气温距平(最近30天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmeana30_',
|
||||
},
|
||||
{
|
||||
title: '气温距平(最近90天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmeana90_',
|
||||
},
|
||||
{
|
||||
title: '最低气温距平(最近30天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmina30_',
|
||||
},
|
||||
{
|
||||
title: '最低气温距平(最近90天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmina90_',
|
||||
},
|
||||
{
|
||||
title: '最高气温距平(最近30天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmaxa30_',
|
||||
},
|
||||
{
|
||||
title: '最高气温距平(最近90天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbtmaxa90_',
|
||||
},
|
||||
{
|
||||
title: '降水量(最近10天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbrain10_',
|
||||
},
|
||||
{
|
||||
title: '降水量(最近20天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbrain20_',
|
||||
},
|
||||
{
|
||||
title: '降水量(最近30天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbrain30_',
|
||||
},
|
||||
{
|
||||
title: '降水量(最近90天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbrain90_',
|
||||
},
|
||||
{
|
||||
title: '降水距平百分率(最近10天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbraina10_',
|
||||
},
|
||||
{
|
||||
title: '降水距平百分率(最近20天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbraina20_',
|
||||
},
|
||||
{
|
||||
title: '降水距平百分率(最近30天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbraina30_',
|
||||
},
|
||||
{
|
||||
title: '降水距平百分率(最近90天)',
|
||||
source: ['cmdp.ncc-cma.net/cn/index.htm'],
|
||||
target: '/cmdp/image/glbraina90_',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,4 +3,6 @@ import type { Namespace } from '@/types';
|
|||
export const namespace: Namespace = {
|
||||
name: '国家气候中心',
|
||||
url: 'cmdp.ncc-cma.net',
|
||||
categories: ['forecast'],
|
||||
description: '',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue