Files
RSSHub/lib/v2/tencent/pvp/newsindex.js
CaoMeiYouRen d7871687a2 fix(route): 修复 王者荣耀 - 新闻列表 pubDate 的解析错误 (#10351)
* feat: 优化B站动态转发内容中的图片和视频

* style: 修复格式错误

* fix: 修复 B站动态转发多图的图片缺失

* style: 整理代码格式

* style: 整理代码格式

* fix: 修复B站动态转发视频缺失标题

* fix: 移除了部分不必要的代码

* fix: 修复b站动态中转发直播间动态出现undefined;整理部分代码

* style: 整理代码格式

* fix: 补充b站动态中转发活动的信息

* fix: 修正代码格式

* fix: b站动态转发专题页缺少标题;整理部分代码

* fix: 修复图片错误

* fix: 修复专栏封面缺失的bug;增加B站动态格式总结

* style:修复格式问题

* fix: 修复/robots.txt路由

* fix

* chore: 合并冲突

* fix

* fix

* feat: 优化B站动态url

* fix: 改 \n 为<br>

* chore: 更新 npm registry

* feat: 完成 米游社路由和文档的编写

* fix: 修复 @vuepress/shared-utils 在 yarn.lock 的缺失

* chore: exact match

* fix: parseDate

* feat(米游社v2): 新增 米游社v2 绝区零 公告

* fix: 修复 王者荣耀 - 新闻列表 pubDate 的解析错误

* refactor: migrate to v2

* docs: fix typo
2022-07-29 20:00:48 +08:00

65 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const map = new Map([
['rm', { name: '热门', channelid: 1760 }],
['xw', { name: '新闻', channelid: 1761 }],
['gg', { name: '公告', channelid: 1762 }],
['hd', { name: '活动', channelid: 1763 }],
['ss', { name: '赛事', channelid: 1764 }],
['yh', { name: '优化', channelid: 1769 }],
['all', { name: '全部', channelid: 0 }],
]);
const link = 'https://pvp.qq.com/web201706/newsindex.shtml';
const apiUrl = 'https://apps.game.qq.com/wmp/v3.1/?p0=18&p1=searchNewsKeywordsList&order=sIdxTime&r0=cors&type=iTarget&source=app_news_search&pagesize=12&page=1&id=';
const pageUrl = `https://pvp.qq.com/web201706/newsdetail.shtml?tid=`;
const getPage = async (id, typeName) => {
const response = await got(apiUrl + id, {
headers: {
Referer: link,
},
});
return Promise.all(
response.data.msg.result.map(async (item) => {
let description = await got(`https://apps.game.qq.com/wmp/v3.1/public/searchNews.php?p0=18&source=web_pc&id=${item.iNewsId}`);
description = JSON.parse(description.data.match(/(?<=var searchObj=).*(?<!;)/g));
return {
title: `${typeName}` + item.sTitle,
link: pageUrl + item.iNewsId,
pubDate: parseDate(item.sTargetIdxTime),
description: description.msg.sContent,
};
})
);
};
module.exports = async (ctx) => {
const type = ctx.params.type;
const OutName = map.get(type).name;
const OutId = map.get(type).channelid;
let item = [];
if (type === 'all') {
const results = await Promise.all(
Array.from(map).map(async (value) => {
const res = await getPage(value[1].channelid, value[1].name);
return res;
})
);
results.forEach((result) => (item = item.concat(result)));
} else {
item = await getPage(OutId, OutName);
}
ctx.state.data = {
title: `${OutName}】 - 王者荣耀 - 新闻列表`,
link,
description: `《王者荣耀》是腾讯天美工作室历时3年推出的东方英雄即时对战手游大作抗塔强杀、团灭超神领略爽热血竞技的酣畅淋漓1v1、3v3、闯关等丰富游戏模式随时战更自由跨服匹配秒开局好友组队战排位不靠装备、没有等级更公平、更爽快的无差异对战`,
item,
};
};