feat(route): add 战争雷霆英文官网-新闻版块 (#10553)

* 添加新的路由lovelive-anime

* 修改部分debug,添加以符合标准

* Update docs/anime.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/lovelive-anime/news.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/lovelive-anime/news.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/lovelive-anime/news.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/lovelive-anime/templates/description.art

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Add en docs

* Add a route for War Thunder

* Add cn en docs

* fix warthunder en doc

* update warthunder doc comments

* fix warthunder doc

* fix warthunder radar

* Update lib/v2/warthunder/news.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/warthunder/radar.js
This commit is contained in:
Axojhf
2022-08-20 20:44:04 +08:00
committed by GitHub
co-authored by Tony
parent 9d9cb75102
commit 0b8aa32918
7 changed files with 86 additions and 0 deletions
+10
View File
@@ -280,3 +280,13 @@ Steam provides some official RSS feeds:
### Discussions
<RouteEn author="whtsky" example="/steamgifts/discussions" path="/steamgifts/discussions/:category?" :paramsDesc="['category name, default to All']"/>
## War Thunder
### News
<RouteEn author="axojhf" example="/warthunder/news" path="/warthunder/news">
News data from https://warthunder.com/en/news/
</RouteEn>
+9
View File
@@ -493,6 +493,15 @@ Steam 新闻中心支持官方的 RSS 订阅:
</Route>
## War Thunder
### 英文News
<Route author="axojhf" example="/warthunder/news" path="/warthunder/news">
News的数据来自 https://warthunder.com/en/news/
</Route>
## 巴哈姆特
### GNN 新聞
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/news': ['axojhf'],
};
+47
View File
@@ -0,0 +1,47 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const path = require('path');
const { art } = require('@/utils/render');
const { parseDate } = require('@/utils/parse-date');
const renderDescription = (desc) => art(path.join(__dirname, 'templates/description.art'), desc);
module.exports = async (ctx) => {
const rootUrl = 'https://warthunder.com/en/news/';
const response = await got(rootUrl);
const $ = cheerio.load(response.data);
const pageFace = $('div.showcase__item.widget')
.map((_, item) => {
item = $(item);
const pubDate = parseDate(item.find('div.widget__content > ul > li').text(), 'D MMMM YYYY');
const category = [];
if (item.find('div.widget__pin').length !== 0) {
category.push('pinned');
}
if (item.find('a.widget__decal').length !== 0) {
category.push('decal');
}
if (item.find('div.widget__badge').length !== 0) {
category.push(item.find('div.widget__badge').text());
}
return {
link: `https://warthunder.com${item.find('a.widget__link').attr('href')}`,
title: item.find('div.widget__content > div.widget__title').text(),
pubDate,
description: renderDescription({
description: item.find('div.widget__content > div.widget__comment').text(),
imglink: item.find('div.widget__poster > img.widget__poster-media').attr('data-src'),
}),
category,
};
})
.get();
ctx.state.data = {
title: 'War Thunder News',
link: 'https://warthunder.com/en/news/',
item: pageFace,
};
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'warthunder.com': {
_name: 'War Thunder',
'.': [
{
title: 'News',
docs: 'https://docs.rsshub.app/game.html#war-thunder-ying-wen-news',
source: ['/en/news', '/'],
target: '/warthunder/news',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/news', require('./news'));
};
@@ -0,0 +1 @@
{{description}}<br><img src="https:{{imglink}}">