Files
RSSHub/lib/routes/vuevideo/user.js
Cloud 9f1a24b2f7 feat: add vuevlog (#2471)
* feat: add vuevlog

* feat: add vuevlog

* feat: add vuevlog
2019-06-24 22:30:56 +08:00

61 lines
1.6 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const userid = ctx.params.userid;
const url = `https://m.vuevideo.net/share/user/${userid}`;
const response = await got({
method: 'get',
url: url,
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('#hotVideosUl li').get();
const author = $('.infoItem.name').text();
const ProcessFeed = (data) => {
const $ = cheerio.load(data);
$('#openBtn').html('APP播放');
// 提取内容
return $('.videoContainer').html() + '<br>' + $('.footer').html();
};
const items = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
const link = $('a').attr('href');
const cache = await ctx.cache.get(link);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const response = await got({
method: 'get',
url: link,
});
const description = ProcessFeed(response.data);
const single = {
title: $('.videoTitle').text(),
description,
link: link,
author: author,
};
ctx.cache.set(link, JSON.stringify(single));
return Promise.resolve(single);
})
);
ctx.state.data = {
title: $('title').text(),
link: url,
description: $('meta[property="og:description"]').attr('content') || $('title').text(),
item: items,
};
};