From e5867d94c2f386e79b6ef5c054632f9490b7a7f3 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Sat, 17 Jul 2021 17:36:32 +0800 Subject: [PATCH] feat(route): add version history of the PotPlayer (#7744) Co-authored-by: NeverBehave --- docs/en/program-update.md | 12 ++++++++++ docs/program-update.md | 12 ++++++++++ lib/router.js | 3 +++ lib/routes/potplayer/update.js | 42 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 lib/routes/potplayer/update.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 6bb7b21f9..c017c91b5 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -253,6 +253,18 @@ Refer to [#minecraft](/en/game.html#minecraft) +## Potplayer + +### Version History + + + +| 한국어 | 中文 (简体) | 中文 (繁体) | ENGLISH | Українська | РУССКИЙ | Polski | +| ------ | ----------- | ----------- | ------- | ---------- | ------- | ------ | +| ko | zh_CN | zh_TW | en | uk | ru | pl | + + + ## PlayStation ### PlayStation 4 System Update diff --git a/docs/program-update.md b/docs/program-update.md index 79064578a..b97b1596f 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -302,6 +302,18 @@ pageClass: routes +## Potplayer + +### 版本历史 + + + +| 한국어 | 中文 (简体) | 中文 (繁体) | ENGLISH | Українська | РУССКИЙ | Polski | +| ------ | ----------- | ----------- | ------- | ---------- | ------- | ------ | +| ko | zh_CN | zh_TW | en | uk | ru | pl | + + + ## PlayStation ### PlayStation 4 系统更新纪录 diff --git a/lib/router.js b/lib/router.js index 2b553a473..79f831566 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4127,6 +4127,9 @@ router.get('/bibgame/:category?/:type?', require('./routes/bibgame/category')); // 澳門特別行政區政府各公共部門獎助貸學金服務平台 router.get('/macau-bolsas/:lang?', require('./routes/macau-bolsas/index')); +// PotPlayer +router.get('/potplayer/update/:language?', require('./routes/potplayer/update')); + // 综艺秀 router.get('/zyshow/:name', require('./routes/zyshow')); diff --git a/lib/routes/potplayer/update.js b/lib/routes/potplayer/update.js new file mode 100644 index 000000000..a47fdffc1 --- /dev/null +++ b/lib/routes/potplayer/update.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const language = ctx.params.language || 'en'; + const bar = '-'.repeat(language.length > 2 ? 74 : 58); + + const rootUrl = 'https://potplayer.daum.net'; + const currentUrl = `${rootUrl}/?lang=${language}`; + + const link = await ctx.cache.tryGet(currentUrl, async () => { + const response = await got({ + method: 'get', + url: currentUrl, + }); + return response.data.match(//)[1]; + }); + + const response = await got({ + method: 'get', + url: link, + }); + + const list = response.data.split(`\r\n\r\n${bar}\r\n`); + + const items = list.slice(1, 10).map((item) => { + const pubDate = parseDate(item.substr(1, 6), 'YYMMDD'); + + return { + pubDate, + link: currentUrl, + title: item.substr(1, 6), + description: `

${item.split(`\r\n${bar}\r\n`)[1].replace(/\r\n/g, '

')}

`, + }; + }); + + ctx.state.data = { + title: list[0].split('\r\n\r\n').pop(), + link: currentUrl, + item: items, + }; +};