feat(route): add gameapps (#8551)

This commit is contained in:
Tony 2021-11-27 10:07:57 +01:00 committed by GitHub
parent 2a5b67304e
commit 3fbfd70970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 0 deletions

View File

@ -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 游资网
### 热点推荐

56
lib/v2/gameapps/index.js Normal file
View File

@ -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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/': ['TonyRL'],
};

13
lib/v2/gameapps/radar.js Normal file
View File

@ -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',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/', require('./index'));
};

View File

@ -0,0 +1,3 @@
<img src="{{ src }}"><br>
{{@ intro }}
{{@ desc }}