Files
RSSHub/lib/v2/zyshow/index.js
Ethan Shen 50f1946e75 fix(route): 综艺秀 (#9898)
* fix(route): 综艺秀

* fix: remove old radar rules
2022-06-05 21:28:45 +08:00

47 lines
1.4 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const rootUrl = 'http://www.zyshow.net';
const currentUrl = `${rootUrl}${ctx.path.replace(/\/$/, '')}/`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const items = $('table')
.last()
.find('tr td a img.icon-play')
.toArray()
.map((item) => {
item = $(item).parentsUntil('tbody');
const a = item.find('a[title]').first();
const guests = item.find('td').eq(2).text();
return {
title: a.text(),
link: `${currentUrl}v/${a.attr('href').split('/v/').pop()}`,
pubDate: parseDate(a.text().match(/(\d{8})$/)[1], 'YYYYMMDD'),
description: art(path.join(__dirname, 'templates/description.art'), {
date: item.find('td').first().text(),
subject: item.find('td').eq(1).text(),
guests,
}),
category: guests.split(/,|;/),
};
});
ctx.state.data = {
title: `综艺秀 - ${$('h2').text()}`,
link: currentUrl,
item: items,
};
};