Files
RSSHub/lib/routes/vol/lastupdate.js
2019-05-15 15:27:15 +08:00

53 lines
1.6 KiB
JavaScript

const axios = require('@/utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
let mode = ctx.params.mode;
let title = ``;
if (mode === 'serial') {
mode = '%E9%80%A3%E8%BC%89';
title = `Vol.moe - serial`;
} else if (mode === 'finish') {
mode = '%E5%AE%8C%E7%B5%90';
title = `Vol.moe - finish`;
} else {
mode = 'all';
title = `Vol.moe`;
}
const link = `http://vol.moe/list/all,all,${mode},lastupdate,all,all,none/`;
const listData = await axios.get(link);
const $list = cheerio.load(listData.data);
const items = $list('.listbg td')
.map((_, el) => {
const $el = $list(el);
const title = $el
.find('a')
.last()
.text();
const imgEL = $el.find('a').first();
const link = imgEL.attr('href');
const imgSrc = imgEL.find('.img_book').attr('src');
const match = $el.text().match(/\[[\s\S]*?\]/g);
const detail = $el.find('.pagefoot').text();
const date = $el.find('.filesize').text();
return {
title: `${title} ${detail} ${match}`,
description: `
<img referrerpolicy="no-referrer" src="${imgSrc}" />
<h1>${title}</h1>
<h2>${match}</h2>
<h2>${detail}</h2>
<h2>${date}</h2>
`.trim(),
link: link,
pubDate: new Date(date).toUTCString(),
};
})
.get();
ctx.state.data = {
title,
link,
item: items,
};
};