feat(route): add Gamer Secret (#8712)

This commit is contained in:
Ethan Shen
2022-01-22 18:25:54 +00:00
committed by GitHub
parent aa6349d74e
commit 1800c1ada2
6 changed files with 165 additions and 0 deletions
+34
View File
@@ -62,6 +62,40 @@ Language codes
<RouteEn author="Zyx-A" example="/epicgames/freegames" path="/epicgames/freegames"/>
## Gamer Secret
### Latest News
<RouteEn author="nczitzk" example="/gamersecret" path="/gamersecret"/>
### Category
<RouteEn author="nczitzk" example="/gamersecret" path="/gamersecret/:type?/:category?" :paramsDesc="['Type, see below, Latest News by default', 'Category, see below']">
| Latest News | PC | Playstation | Nintendo | Xbox | Moblie |
| ----------- | -- | ----------- | -------- | ---- | ------ |
| latest-news | pc | playstation | nintendo | xbox | moblie |
Or
| GENERAL | GENERAL EN | MOBILE | MOBILE EN |
| ---------------- | ------------------ | --------------- | ----------------- |
| category/general | category/generalen | category/mobile | category/mobileen |
| NINTENDO | NINTENDO EN | PC | PC EN |
| ----------------- | ------------------- | ----------- | ------------- |
| category/nintendo | category/nintendoen | category/pc | category/pcen |
| PLAYSTATION | PLAYSTATION EN | REVIEWS |
| -------------------- | ---------------------- | ---------------- |
| category/playstation | category/playstationen | category/reviews |
| XBOX | XBOX EN |
| ------------- | --------------- |
| category/xbox | category/xboxen |
</RouteEn>
## Konami
### PES Mobile Announcement
+34
View File
@@ -151,6 +151,40 @@ pageClass: routes
</Route>
## Gamer Secret
### 最新資訊
<Route author="nczitzk" example="/gamersecret" path="/gamersecret"/>
### 分類
<Route author="nczitzk" example="/gamersecret/pc" path="/gamersecret/:type?/:category?" :paramsDesc="['类型,见下表,默认为 Latest News', '分类,见下表,默认为空']">
| Latest News | PC | Playstation | Nintendo | Xbox | Moblie |
| ----------- | -- | ----------- | -------- | ---- | ------ |
| latest-news | pc | playstation | nintendo | xbox | moblie |
或者
| GENERAL | GENERAL EN | MOBILE | MOBILE EN |
| ---------------- | ------------------ | --------------- | ----------------- |
| category/general | category/generalen | category/mobile | category/mobileen |
| NINTENDO | NINTENDO EN | PC | PC EN |
| ----------------- | ------------------- | ----------- | ------------- |
| category/nintendo | category/nintendoen | category/pc | category/pcen |
| PLAYSTATION | PLAYSTATION EN | REVIEWS |
| -------------------- | ---------------------- | ---------------- |
| category/playstation | category/playstationen | category/reviews |
| XBOX | XBOX EN |
| ------------- | --------------- |
| category/xbox | category/xboxen |
</Route>
## GNN.tw 游戏新闻
### GNN.tw 游戏新闻
+60
View File
@@ -0,0 +1,60 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const type = ctx.params.type ?? 'latest-news';
const category = ctx.params.category ?? '';
const rootUrl = 'https://www.gamersecret.com';
const currentUrl = `${rootUrl}/${type}${category ? `/${category}` : ''}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('.jeg_post_title a')
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: item.attr('href'),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
content('img').each(function () {
content(this).attr('src', content(this).attr('data-src'));
});
item.author = content('.jeg_meta_author').text().replace(/by/, '');
item.pubDate = timezone(parseDate(detailResponse.data.match(/datePublished":"(.*)","dateModified/)[1]), +8);
item.description = content('.thumbnail-container').html() + content('.elementor-text-editor, .content-inner').html();
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:type?/:category?': ['nczitzk'],
};
+31
View File
@@ -0,0 +1,31 @@
module.exports = {
'gamersecret.com': {
_name: 'Gamer Secret',
'.': [
{
title: '最新資訊',
docs: 'https://docs.rsshub.app/game.html#gamer-secret-zui-xin-zi-xun',
source: ['/:type', '/:type/:category', '/'],
target: '/gamersecret',
},
{
title: '分類',
docs: 'https://docs.rsshub.app/game.html#gamer-secret-fen-lei',
source: ['/:type', '/:type/:category', '/'],
target: '/gamersecret/:type?/:category?',
},
{
title: 'Latest News',
docs: 'https://docs.rsshub.app/game.html#gamer-secret-latest-news',
source: ['/:type', '/:type/:category', '/'],
target: '/gamersecret',
},
{
title: 'Category',
docs: 'https://docs.rsshub.app/game.html#gamer-secret-category',
source: ['/:type', '/:type/:category', '/'],
target: '/gamersecret/:type?/:category?',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:type?/:category?', require('./index'));
};