Files
RSSHub/lib/routes/ymgal/game.ts
T
Tony a5e2e295dc refactor: fix all get to toArray (#19000)
* refactor: fix all get

* fix(utils/common-config): charset case compare

* Revert "fix(utils/common-config): charset case compare"

This reverts commit 3c1880f2fad53ad2cafddcee7741390fd46fa3d2.

* fix: nga

* fix: notateslaapp

* fix: ps

* fix: xjtu

* fix: enforce error on restricted syntax for get calls

* fix: eslint

* fix: more eslint
2025-05-04 05:24:53 +08:00

68 lines
1.8 KiB
TypeScript

import { Route } from '@/types';
import got from '@/utils/got';
import { art } from '@/utils/render';
import path from 'node:path';
import { load } from 'cheerio';
const host = 'https://www.ymgal.games';
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
export const route: Route = {
path: '/game/release',
categories: ['anime'],
example: '/ymgal/game/release',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['ymgal.games/'],
},
],
name: '本月新作',
maintainers: ['SunBK201'],
handler,
url: 'ymgal.games/',
};
async function handler() {
const response = await got({
method: 'get',
url: `${host}/release-list/${year}/${month}`,
});
const $ = 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');
const tags = item.find('.tag-info-list').children();
const taginfo = tags.toArray().map((elem) => $(elem).text());
return {
title: item.attr('title'),
link: `${host}${item.attr('href')}`,
description: art(path.join(__dirname, 'templates/description.art'), { itemPicUrl, taginfo }),
};
});
return {
title: `月幕 Galgame - 本月新作`,
link: `${host}/release-list/${year}/${month}`,
description: '月幕 Galgame - 本月新作',
item: items,
};
}