mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 01:58:11 +08:00
feat(route): 新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 (#11467)
* feat(route): 添加 百度股市通 * fix: 修改 百度股市通 路径 * docs: 添加 百度股市通 文档 * feat: 添加 radar 支持 * fix: 按字母顺序插入新路由 * feat(route): 新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 * fix: 优化 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的标题 * fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 部分情况下的非空判断 * fix: 修复 地区名称标题的问题 * fix: 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 guid 增加 pubDate * fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 guid 中添加 pubDate * fix: 修改 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 title
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
module.exports = {
|
||||
'/cloud/column/:id?/:tag?': ['nczitzk'],
|
||||
'/news/coronavirus/data/:province?/:city?': ['CaoMeiYouRen'],
|
||||
'/news/coronavirus/total': ['CaoMeiYouRen'],
|
||||
'/pvp/newsindex/:type': ['Jeason0228', 'HenryQW'],
|
||||
'/qq/sdk/changelog/:platform': ['nuomi1'],
|
||||
};
|
||||
|
||||
71
lib/v2/tencent/news/coronavirus/data.js
Normal file
71
lib/v2/tencent/news/coronavirus/data.js
Normal file
@@ -0,0 +1,71 @@
|
||||
const { getData } = require('./utils');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const province = ctx.params.province || '';
|
||||
const city = ctx.params.city || '';
|
||||
|
||||
const link = 'https://news.qq.com/zt2020/page/feiyan.htm#/';
|
||||
const item = [];
|
||||
|
||||
const diseaseh5Shelf = (await getData(['diseaseh5Shelf']))?.data?.diseaseh5Shelf || {};
|
||||
const { lastUpdateTime, areaTree } = diseaseh5Shelf;
|
||||
const nationalData = areaTree?.[0];
|
||||
const provinceList = nationalData?.children;
|
||||
|
||||
let todayConfirm = 0;
|
||||
let totalNowConfirm = 0;
|
||||
let totalConfirm = 0;
|
||||
let totalDead = 0;
|
||||
let coronavirusData = {};
|
||||
let placeName = '';
|
||||
|
||||
if (!province || province === '中国' || province === '全国') {
|
||||
// 没有传参则取全国
|
||||
coronavirusData = nationalData;
|
||||
placeName = '中国';
|
||||
} else {
|
||||
// 分省份获取
|
||||
coronavirusData = provinceList?.find((e) => e.name === province);
|
||||
placeName = province;
|
||||
if (city) {
|
||||
// 继续获取 区县 数据
|
||||
coronavirusData = coronavirusData?.children?.find((e) => e.name === city);
|
||||
if (coronavirusData) {
|
||||
placeName = `${province}-${city}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!coronavirusData) {
|
||||
throw new Error(`未找到 ${placeName} 的疫情数据,请检查输入的省市名称是否正确`);
|
||||
}
|
||||
todayConfirm = coronavirusData.today?.confirm;
|
||||
totalNowConfirm = coronavirusData.total?.nowConfirm;
|
||||
totalConfirm = coronavirusData.total?.confirm;
|
||||
totalDead = coronavirusData.total?.dead;
|
||||
const pubDate = parseDate(coronavirusData.total?.mtime || lastUpdateTime);
|
||||
|
||||
const title = `${placeName} - 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪`;
|
||||
|
||||
const info = {
|
||||
title: `${placeName} - 疫情数据`,
|
||||
description: art(path.join(__dirname, '../../templates/coronavirus/data.art'), {
|
||||
todayConfirm,
|
||||
totalNowConfirm,
|
||||
totalConfirm,
|
||||
totalDead,
|
||||
}),
|
||||
pubDate,
|
||||
guid: `${link}${placeName}?pubDate=${pubDate.toISOString()}`,
|
||||
};
|
||||
|
||||
item.push(info);
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link,
|
||||
item,
|
||||
};
|
||||
};
|
||||
34
lib/v2/tencent/news/coronavirus/total.js
Normal file
34
lib/v2/tencent/news/coronavirus/total.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const { getData } = require('./utils');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const title = '腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪';
|
||||
const link = 'https://news.qq.com/zt2020/page/feiyan.htm#/';
|
||||
const item = [];
|
||||
|
||||
const chinaTotal = (await getData(['diseaseh5Shelf']))?.data?.diseaseh5Shelf?.chinaTotal || {};
|
||||
const { localConfirmH5, localWzzAdd, confirmAdd, localConfirm, nowLocalWzz, highRiskAreaNum, mtime } = chinaTotal;
|
||||
const pubDate = parseDate(mtime);
|
||||
const info = {
|
||||
title: '中国本土数据统计',
|
||||
description: art(path.join(__dirname, '../../templates/coronavirus/chinaTotal.art'), {
|
||||
localConfirmH5,
|
||||
localWzzAdd,
|
||||
confirmAdd,
|
||||
localConfirm,
|
||||
nowLocalWzz,
|
||||
highRiskAreaNum,
|
||||
}),
|
||||
pubDate,
|
||||
guid: `${link}total?pubDate=${pubDate.toISOString()}`,
|
||||
};
|
||||
item.push(info);
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link,
|
||||
item,
|
||||
};
|
||||
};
|
||||
17
lib/v2/tencent/news/coronavirus/utils.js
Normal file
17
lib/v2/tencent/news/coronavirus/utils.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author CaoMeiYouRen
|
||||
* @date 2022-12-18
|
||||
* @param {string[]} [modules=[]] localCityNCOVDataList,diseaseh5Shelf,nowConfirmStatis,provinceCompare,FAutoforeignList,FAutoCountryConfirmAdd,WomWorld,WomAboard,VaccineTopData
|
||||
*/
|
||||
const getData = async (modules = []) => {
|
||||
const response = await got('https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=' + modules.join(','));
|
||||
return response.data;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getData,
|
||||
};
|
||||
@@ -27,6 +27,14 @@ module.exports = {
|
||||
target: (params, url) => `/wechat/mp/msgalbum/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('album_id')}`,
|
||||
},
|
||||
],
|
||||
news: [
|
||||
{
|
||||
title: '腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪',
|
||||
docs: 'https://docs.rsshub.app/other.html#xin-guan-fei-yan-yi-qing-xin-wen-dong-tai',
|
||||
source: ['/zt2020/page/feiyan.htm#/'],
|
||||
target: '/tencent/news/coronavirus/total',
|
||||
},
|
||||
],
|
||||
pvp: [
|
||||
{
|
||||
title: '王者荣耀 - 新闻中心',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/cloud/column/:id?/:tag?', require('./cloud/column'));
|
||||
router.get('/news/coronavirus/data/:province?/:city?', require('./news/coronavirus/data'));
|
||||
router.get('/news/coronavirus/total', require('./news/coronavirus/total'));
|
||||
router.get('/pvp/newsindex/:type', require('./pvp/newsindex'));
|
||||
router.get('/qq/sdk/changelog/:platform', require('./qq/sdk/changelog'));
|
||||
};
|
||||
|
||||
6
lib/v2/tencent/templates/coronavirus/chinaTotal.art
Normal file
6
lib/v2/tencent/templates/coronavirus/chinaTotal.art
Normal file
@@ -0,0 +1,6 @@
|
||||
<p>本土确诊:</p><p>+{{@localConfirmH5}}</p></br>
|
||||
<p>本土无症状:</p><p>+{{@localWzzAdd}}</p></br>
|
||||
<p>确诊病例:</p><p>+{{@confirmAdd}}</p></br>
|
||||
<p>现有本土确诊:</p><p>{{@localConfirm}}</p></br>
|
||||
<p>现有本土无症状:</p><p>{{@nowLocalWzz}}</p></br>
|
||||
<p>高风险地区:</p><p>{{@highRiskAreaNum}}</p></br>
|
||||
4
lib/v2/tencent/templates/coronavirus/data.art
Normal file
4
lib/v2/tencent/templates/coronavirus/data.art
Normal file
@@ -0,0 +1,4 @@
|
||||
<p>新增确诊:</p><p>+{{@todayConfirm}}</p></br>
|
||||
<p>现有确诊:</p><p>{{@totalNowConfirm}}</p></br>
|
||||
<p>累计确诊:</p><p>{{@totalConfirm}}</p></br>
|
||||
<p>累计死亡:</p><p>{{@totalDead}}</p></br>
|
||||
Reference in New Issue
Block a user