feat(route): Add wmpvp (#14586)

This commit is contained in:
tssujt 2024-02-29 11:02:52 +08:00 committed by GitHub
parent 1badc67a6a
commit 0a9f1f8067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 61 additions and 0 deletions

34
lib/v2/wmpvp/index.js Normal file
View File

@ -0,0 +1,34 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const { type } = ctx.params;
const response = await got({
method: 'get',
url: `https://appengine.wmpvp.com/steamcn/community/homepage/getHomeInformation?gameTypeStr=${type}&pageNum=1&pageSize=20`,
});
const data = response.data.result.filter((item) => item.news !== undefined);
const items = data.map((item) => {
const entity = item.news;
const newsId = entity.newsId;
const newsLink = `https://news.wmpvp.com/news.html?id=${newsId}&gameTypeStr=${type}`;
// 最终需要返回的对象
return {
title: entity.title,
pubDate: parseDate(entity.publishTime),
link: newsLink,
guid: newsLink,
description: entity.summary,
author: entity.author,
};
});
ctx.state.data = {
title: `完美世界电竞`,
link: `https://news.wmpvp.com/`,
item: items,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/news/:type': ['tssujt'],
};

11
lib/v2/wmpvp/radar.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
'wmpvp.com': {
_name: '完美世界电竞',
'.': [
{
title: '资讯',
docs: 'https://docs.rsshub.app/routes/game#wan-mei-shi-jie-dian-jing-zi-xun',
},
],
},
};

3
lib/v2/wmpvp/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news/:type', require('.'));
};

View File

@ -903,6 +903,16 @@ Example`https://www.iyingdi.com/tz/people/55547` id 是 `55547`
<Route author="luyuhuang" example="/163/ds/63dfbaf4117741daaf73404601165843" path="/163/ds/:id" paramsDesc={['用户ID']} />
## 完美世界电竞 {#wan-mei-shi-jie-dian-jing}
### 资讯列表 {#wan-mei-shi-jie-dian-jing-zi-xun}
<Route author="tssujt" example="/wmpvp/news/1" path="/wmpvp/news/:type" paramsDesc={['资讯分类,见下表']}>
| DOTA2 | CS2 |
| ---- | ---- |
| 1 | 2 |
</Route>
## 小黑盒 {#xiao-hei-he}
### 用户动态 {#xiao-hei-he-yong-hu-dong-tai}