From 09e6ee4d26c68c81658e3d4fbe700e0ee1a1bbd7 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 12 Oct 2022 17:55:33 +0400 Subject: [PATCH] fix(route): ft (#11071) --- lib/v2/ft/maintainer.js | 4 ++-- lib/v2/ft/utils.js | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/v2/ft/maintainer.js b/lib/v2/ft/maintainer.js index cdbeeec83..3aa646268 100644 --- a/lib/v2/ft/maintainer.js +++ b/lib/v2/ft/maintainer.js @@ -1,4 +1,4 @@ module.exports = { - '/ft/myft/:key': ['HenryQW'], - '/ft/:language/:channel?': ['HenryQW', 'xyqfer'], + '/myft/:key': ['HenryQW'], + '/:language/:channel?': ['HenryQW', 'xyqfer'], }; diff --git a/lib/v2/ft/utils.js b/lib/v2/ft/utils.js index 1e6a15378..886a43392 100644 --- a/lib/v2/ft/utils.js +++ b/lib/v2/ft/utils.js @@ -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; }); })