feat(route): add gameapps (#8551)
This commit is contained in:
parent
2a5b67304e
commit
3fbfd70970
|
|
@ -103,6 +103,12 @@ pageClass: routes
|
|||
|
||||
<Route author="nczitzk" example="/fgo/news" path="/fgo/news"/>
|
||||
|
||||
## GameApps.hk 香港手机游戏网
|
||||
|
||||
### 最新消息
|
||||
|
||||
<Route author="TonyRL" example="/gameapps" path="/gameapps"/>
|
||||
|
||||
## GameRes 游资网
|
||||
|
||||
### 热点推荐
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
const got = require('@/utils/got');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.gameapps.hk';
|
||||
const feed = await parser.parseURL(`https://www.gameapps.hk/rss`);
|
||||
|
||||
const items = await Promise.all(
|
||||
feed.items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got({
|
||||
url: item.link,
|
||||
headers: {
|
||||
Referer: baseUrl,
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
// remove unwanted key value
|
||||
delete item.content;
|
||||
delete item.contentSnippet;
|
||||
delete item.isoDate;
|
||||
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
src: $('div.introduction.media.news-intro div.media-left').find('img').attr('src'),
|
||||
intro: $('div.introduction.media.news-intro div.media-body').html().trim(),
|
||||
desc: $('.news-content').html().trim(),
|
||||
});
|
||||
item.guid = item.guid.substring(0, item.link.lastIndexOf('/'));
|
||||
item.pubDate = parseDate(item.pubDate);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: feed.title,
|
||||
link: feed.link,
|
||||
description: feed.description,
|
||||
item: items,
|
||||
language: feed.language,
|
||||
};
|
||||
|
||||
ctx.state.json = {
|
||||
title: feed.title,
|
||||
link: feed.link,
|
||||
description: feed.description,
|
||||
item: items,
|
||||
language: feed.language,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/': ['TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'gameapps.hk': {
|
||||
_name: 'GameApps.hk 香港手机游戏网',
|
||||
'.': [
|
||||
{
|
||||
title: '最新消息',
|
||||
docs: 'https://docs.rsshub.app/game.html#gameapps-hk-xiang-gang-shou-ji-you-xi-wang',
|
||||
source: ['/'],
|
||||
target: '/gameapps',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/', require('./index'));
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<img src="{{ src }}"><br>
|
||||
{{@ intro }}
|
||||
{{@ desc }}
|
||||
Loading…
Reference in New Issue