feat(route): add version history of the PotPlayer (#7744)

Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
Ethan Shen 2021-07-17 17:36:32 +08:00 committed by GitHub
parent e11a0615e1
commit e5867d94c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 0 deletions

View File

@ -253,6 +253,18 @@ Refer to [#minecraft](/en/game.html#minecraft)
<RouteEn author="nczitzk" example="/obsidian/announcements" path="/obsidian/announcements"/>
## Potplayer
### Version History
<RouteEn author="nczitzk" example="/potplayer/update" path="/potplayer/update/:language?" :paramsDesc="['Language, see below, English by default']">
| 한국어 | 中文 (简体) | 中文 (繁体) | ENGLISH | Українська | РУССКИЙ | Polski |
| ------ | ----------- | ----------- | ------- | ---------- | ------- | ------ |
| ko | zh_CN | zh_TW | en | uk | ru | pl |
</RouteEn>
## PlayStation
### PlayStation 4 System Update

View File

@ -302,6 +302,18 @@ pageClass: routes
<Route author="nczitzk" example="/onenotegem/release" path="/onenotegem/release"/>
## Potplayer
### 版本历史
<Route author="nczitzk" example="/potplayer/update" path="/potplayer/update/:language?" :paramsDesc="['语言,见下表,默认为英语']">
| 한국어 | 中文 (简体) | 中文 (繁体) | ENGLISH | Українська | РУССКИЙ | Polski |
| ------ | ----------- | ----------- | ------- | ---------- | ------- | ------ |
| ko | zh_CN | zh_TW | en | uk | ru | pl |
</Route>
## PlayStation
### PlayStation 4 系统更新纪录

View File

@ -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'));

View File

@ -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(/<a href="(.*)" class="link_update">/)[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: `<div><p>${item.split(`\r\n${bar}\r\n`)[1].replace(/\r\n/g, '</p><p>')}</p></div>`,
};
});
ctx.state.data = {
title: list[0].split('\r\n\r\n').pop(),
link: currentUrl,
item: items,
};
};