feat(route): ymgal game release (#11435)

* feat(route): Add 月幕 Galgame RSS

* fix(route): improve cache and fix radar path

* feat(route): add all type

* docs: fix param

* fix: sort publishTime

* feat(route): ymgal game release

* fix:

* fix: use art-template
This commit is contained in:
SunBK201 2022-12-12 22:51:23 +08:00 committed by GitHub
parent b55f4f0c08
commit 80fd91b896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 4 deletions

View File

@ -717,12 +717,16 @@ Sources
<Route author="SunBK201" example="/ymgal/article" path="/ymgal/article/:type?" :paramsDesc="['文章类型']" radar="1">
| All | 资讯 | 专栏 |
| --- | ---- | ------ |
| all | news | column |
| 全部文章 | 资讯 | 专栏 |
| ---- | ---- | ------ |
| all | news | column |
</Route>
### 本月新作
<Route author="SunBK201" example="/ymgal/game/release" path="/ymgal/game/release" radar="1" />
## 终点分享
### 最新汉化

View File

@ -54,7 +54,7 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: `月幕 Galgame - ${info}`,
link: 'https://www.ymgal.games/co/article',
link: `${host}/co/article`,
description: `月幕 Galgame - ${info}`,
item: items,
};

39
lib/v2/ymgal/game.js Normal file
View File

@ -0,0 +1,39 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const cheerio = require('cheerio');
const host = 'https://www.ymgal.games';
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: `${host}/release-list/${year}/${month}`,
});
const $ = cheerio.load(response.data);
const list = $('.game-view-card').toArray();
const items =
list &&
list.map((item) => {
item = $(item);
const itemPicUrl = item.find('.lazy').first().attr('data-original');
return {
title: item.attr('title'),
link: `${host}${item.attr('href')}`,
description: art(path.join(__dirname, 'templates/description.art'), { itemPicUrl }),
};
});
ctx.state.data = {
title: `月幕 Galgame - 本月新作`,
link: `${host}/release-list/${year}/${month}`,
description: '月幕 Galgame - 本月新作',
item: items,
};
};

View File

@ -20,6 +20,12 @@ module.exports = {
source: ['/co/article'],
target: '/ymgal/article/column',
},
{
title: '本月新作',
docs: 'https://docs.rsshub.app/anime.html#yue-mu-galgame',
source: ['/'],
target: '/ymgal/game/release',
},
],
},
};

View File

@ -1,3 +1,4 @@
module.exports = (router) => {
router.get('/article/:type?', require('./article'));
router.get('/game/release', require('./game'));
};

View File

@ -0,0 +1,3 @@
{{ if itemPicUrl }}
<img src="{{ itemPicUrl }}">
{{ /if }}