fix(route): ft (#11071)

This commit is contained in:
Tony
2022-10-12 17:55:33 +04:00
committed by GitHub
parent ce8d3d3184
commit 09e6ee4d26
2 changed files with 12 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
module.exports = {
'/ft/myft/:key': ['HenryQW'],
'/ft/:language/:channel?': ['HenryQW', 'xyqfer'],
'/myft/:key': ['HenryQW'],
'/:language/:channel?': ['HenryQW', 'xyqfer'],
};

View File

@@ -2,9 +2,9 @@ const got = require('@/utils/got');
const parser = require('@/utils/rss-parser');
const cheerio = require('cheerio');
const ProcessFeed = ($, link) => {
const ProcessFeed = (i, $, link) => {
const title = $('h1').text();
let content = $('div.story-container');
let content = $('div.story-container').eq(i);
// 处理封面图片
content.find('div.story-image > figure').each((_, e) => {
@@ -59,17 +59,20 @@ const getData = async ({ site = 'www', channel, ctx }) => {
}
const items = await Promise.all(
feed.items.splice(0, 10).map((item) => {
feed.items.map((item) => {
item.link = item.link.replace('http://', 'https://');
return ctx.cache.tryGet(item.link, async () => {
const response = await got.get(`${item.link}?full=y&archive`);
const $ = cheerio.load(response.data);
const result = ProcessFeed($, item.link);
const results = [];
for (let i = 0; i < $('div.story-container').length; i++) {
results.push(ProcessFeed(i, $, item.link));
}
item.title = result.title;
item.description = result.content;
item.author = result.author;
item.title = results[0].title;
item.description = results.map((result) => result.content).join('');
item.author = results[0].author;
return item;
});
})