* 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
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
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,
|
|
};
|
|
};
|