diff --git a/lib/router.js b/lib/router.js index 36a357b75..aa8fa4323 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2116,7 +2116,7 @@ router.get('/sagawa/:id', lazyloadRouteHandler('./routes/sagawa/index')); router.get('/qnap/release-notes/:id', lazyloadRouteHandler('./routes/qnap/release-notes')); // Liquipedia -router.get('/liquipedia/dota2/matches/:id', lazyloadRouteHandler('./routes/liquipedia/dota2_matches.js')); +// router.get('/liquipedia/dota2/matches/:id', lazyloadRouteHandler('./routes/liquipedia/dota2_matches.js')); // 哈尔滨市科技局 router.get('/gov/harbin/kjj', lazyloadRouteHandler('./routes/gov/harbin/kjj')); diff --git a/lib/routes/liquipedia/dota2_matches.js b/lib/routes/liquipedia/dota2_matches.js deleted file mode 100644 index 02fde1bdd..000000000 --- a/lib/routes/liquipedia/dota2_matches.js +++ /dev/null @@ -1,50 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const team = ctx.params.id; - const url = `https://liquipedia.net/dota2/${team}`; - const response = await got({ - method: 'get', - url, - }); - - const data = response.data; - - const $ = cheerio.load(data); - const list = $('div.recent-matches > table > tbody > tr[style]'); - - ctx.state.data = { - title: `Liquipedia Dota2 ${team} Matches`, - link: url, - item: - list && - list - .map((index, item) => { - item = $(item); - let message = ''; - if (item.attr('style') === 'background:rgb(240, 255, 240)') { - message = '胜'; - } else if (item.attr('style') === 'background:rgb(249, 240, 242)') { - message = '败'; - } else { - message = '平'; - } - const date = item.find('td:nth-child(1)').text(); - const time = item.find('td:nth-child(2)').text(); - const tournament = item.find('td:nth-child(5) > a').text(); - const date_time = new Date(date + ' ' + time).toUTCString(); - const score = item.find('td:nth-child(6)').text(); - const vs_team = item.find('td:nth-child(7) > span > span.team-template-text > a').text(); - - return { - title: `[${message}] ${score} ${vs_team}`, - description: `At ${tournament}, ${team} ${score} ${vs_team}`, - pubDate: date_time, - link: url, - guid: url + date_time, - }; - }) - .get(), - }; -}; diff --git a/lib/v2/liquipedia/cs_matches.js b/lib/v2/liquipedia/cs_matches.js new file mode 100644 index 000000000..4f6f0c371 --- /dev/null +++ b/lib/v2/liquipedia/cs_matches.js @@ -0,0 +1,52 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const team = ctx.params.team; + + const rootUrl = 'https://liquipedia.net'; + const currentUrl = `${rootUrl}/counterstrike/${team}/Matches`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + const list = $('.recent-matches-bg-lose, .recent-matches-bg-win'); + + const matches = list + .map((_, item) => { + item = $(item); + + const getRes = () => { + if (item.attr('class') === 'recent-matches-bg-lose') { + return 'LOSS'; + } else { + return 'WIN'; + } + }; + const result = getRes(); + + const infoList = item.find('td'); + + const time = infoList.eq(0).text() + ' ' + infoList.eq(1).text(); + const tournament = infoList.eq(6).text(); + const score = infoList.eq(7).text(); + const opponent = infoList.eq(8).text(); + + return { + title: `[${result}] ${team} ${score} ${opponent} on ${tournament}`, + description: `${time}, ${team} ${score} ${opponent} on ${tournament}`, + link: currentUrl, + guid: currentUrl + time, + }; + }) + .get(); + + ctx.state.data = { + title: `[Counter-Strike] ${team} Match Results From Liquipedia`, + link: currentUrl, + item: matches, + }; +}; diff --git a/lib/v2/liquipedia/dota2_matches.js b/lib/v2/liquipedia/dota2_matches.js new file mode 100644 index 000000000..aaed4abf3 --- /dev/null +++ b/lib/v2/liquipedia/dota2_matches.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const team = ctx.params.id; + const url = `https://liquipedia.net/dota2/${team}`; + const response = await got({ + method: 'get', + url, + }); + + const data = response.data; + + const $ = cheerio.load(data); + const list = $('div.recent-matches > table > tbody > tr[style]'); + + ctx.state.data = { + title: `Liquipedia Dota2 ${team} Matches`, + link: url, + item: list?.toArray().map((item) => { + item = $(item); + let message = ''; + if (item.attr('style') === 'background:rgb(240, 255, 240)') { + message = '胜'; + } else if (item.attr('style') === 'background:rgb(249, 240, 242)') { + message = '败'; + } else { + message = '平'; + } + const date = item.find('td:nth-child(1)').text(); + const time = item.find('td:nth-child(2)').text(); + const tournament = item.find('td:nth-child(6) > a').text(); + const dateTime = parseDate(date + ' ' + time); + const score = item.find('td:nth-child(7)').text(); + const vs_team = item.find('td:nth-child(8) > span > span.team-template-text > a').text(); + + return { + title: `[${message}] ${score} ${vs_team}`, + description: `At ${tournament}, ${team} ${score} ${vs_team}`, + pubDate: dateTime, + link: url, + guid: url + dateTime, + }; + }), + }; +}; diff --git a/lib/v2/liquipedia/maintainer.js b/lib/v2/liquipedia/maintainer.js new file mode 100644 index 000000000..d83acb72d --- /dev/null +++ b/lib/v2/liquipedia/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/counterstrike/matches/:team': ['CookiePieWw'], + '/dota2/matches/:id': ['wzekin'], +}; diff --git a/lib/v2/liquipedia/radar.js b/lib/v2/liquipedia/radar.js new file mode 100644 index 000000000..13fe9a4b8 --- /dev/null +++ b/lib/v2/liquipedia/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'liquipedia.net': { + _name: 'Liquipedia', + '.': [ + { + title: 'Counter Strike Match Results', + docs: 'https://docs.rsshub.app/routes/game#liquipedia', + source: ['/counterstrike/:id/Matches', '/dota2/:id'], + target: '/liquipedia/counterstrike/matches/:id', + }, + { + title: 'Dota2 战队最近比赛结果', + docs: 'https://docs.rsshub.app/routes/game#liquipedia', + source: ['/dota2/:id'], + target: '/liquipedia/dota2/matches/:id', + }, + ], + }, +}; diff --git a/lib/v2/liquipedia/router.js b/lib/v2/liquipedia/router.js new file mode 100644 index 000000000..f741f14e3 --- /dev/null +++ b/lib/v2/liquipedia/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/counterstrike/matches/:team', require('./cs_matches.js')); + router.get('/dota2/matches/:id', require('./dota2_matches.js')); +}; diff --git a/website/docs/routes/game.mdx b/website/docs/routes/game.mdx index fe9358c35..8ef201e7c 100644 --- a/website/docs/routes/game.mdx +++ b/website/docs/routes/game.mdx @@ -318,19 +318,23 @@ So the route is [`/itch/devlogs/teamterrible/the-baby-in-yellow`](https://rsshub ### PES Mobile Announcement {#konami-pes-mobile-announcement} - + ## Liquipedia {#liquipedia} ### Dota2 战队最近比赛结果 {#liquipedia-dota2-zhan-dui-zui-jin-bi-sai-jie-guo} - + + +### Counter Strike Match Results {#liquipedia-cs-match-results} + + ## Maxjia News {#maxjia-news} ### Dota 2 {#maxjia-news-dota-2} - + ## Minecraft {#minecraft}