From 0b8aa32918d82f167d5bb0927050dec58bf6d76d Mon Sep 17 00:00:00 2001 From: Axojhf <20625305+axojhf@users.noreply.github.com> Date: Sat, 20 Aug 2022 20:44:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E6=88=98=E4=BA=89?= =?UTF-8?q?=E9=9B=B7=E9=9C=86=E8=8B=B1=E6=96=87=E5=AE=98=E7=BD=91-?= =?UTF-8?q?=E6=96=B0=E9=97=BB=E7=89=88=E5=9D=97=20(#10553)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加新的路由lovelive-anime * 修改部分debug,添加以符合标准 * Update docs/anime.md Co-authored-by: Tony * Update lib/v2/lovelive-anime/news.js Co-authored-by: Tony * Update lib/v2/lovelive-anime/news.js Co-authored-by: Tony * Update lib/v2/lovelive-anime/news.js Co-authored-by: Tony * Update lib/v2/lovelive-anime/templates/description.art Co-authored-by: Tony * 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 * Update lib/v2/warthunder/radar.js --- docs/en/game.md | 10 +++++ docs/game.md | 9 ++++ lib/v2/warthunder/maintainer.js | 3 ++ lib/v2/warthunder/news.js | 47 +++++++++++++++++++++ lib/v2/warthunder/radar.js | 13 ++++++ lib/v2/warthunder/router.js | 3 ++ lib/v2/warthunder/templates/description.art | 1 + 7 files changed, 86 insertions(+) create mode 100644 lib/v2/warthunder/maintainer.js create mode 100644 lib/v2/warthunder/news.js create mode 100644 lib/v2/warthunder/radar.js create mode 100644 lib/v2/warthunder/router.js create mode 100644 lib/v2/warthunder/templates/description.art diff --git a/docs/en/game.md b/docs/en/game.md index bfca65aa8b..a8d269ea7b 100755 --- a/docs/en/game.md +++ b/docs/en/game.md @@ -280,3 +280,13 @@ Steam provides some official RSS feeds: ### Discussions + +## War Thunder + +### News + + + +News data from https://warthunder.com/en/news/ + + \ No newline at end of file diff --git a/docs/game.md b/docs/game.md index a8de4e39d7..5bfc52949a 100644 --- a/docs/game.md +++ b/docs/game.md @@ -493,6 +493,15 @@ Steam 新闻中心支持官方的 RSS 订阅: +## War Thunder + +### 英文News + + +News的数据来自 https://warthunder.com/en/news/ + + + ## 巴哈姆特 ### GNN 新聞 diff --git a/lib/v2/warthunder/maintainer.js b/lib/v2/warthunder/maintainer.js new file mode 100644 index 0000000000..5a72442e82 --- /dev/null +++ b/lib/v2/warthunder/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news': ['axojhf'], +}; diff --git a/lib/v2/warthunder/news.js b/lib/v2/warthunder/news.js new file mode 100644 index 0000000000..a15727982f --- /dev/null +++ b/lib/v2/warthunder/news.js @@ -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, + }; +}; diff --git a/lib/v2/warthunder/radar.js b/lib/v2/warthunder/radar.js new file mode 100644 index 0000000000..e8ecabc059 --- /dev/null +++ b/lib/v2/warthunder/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/warthunder/router.js b/lib/v2/warthunder/router.js new file mode 100644 index 0000000000..630036b8e4 --- /dev/null +++ b/lib/v2/warthunder/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/news', require('./news')); +}; diff --git a/lib/v2/warthunder/templates/description.art b/lib/v2/warthunder/templates/description.art new file mode 100644 index 0000000000..48f2982380 --- /dev/null +++ b/lib/v2/warthunder/templates/description.art @@ -0,0 +1 @@ +{{description}}
\ No newline at end of file