From 3f9154fb7208cf6f377375d9f8d4875c21f33f4a Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 25 Jan 2021 03:40:44 +0800 Subject: [PATCH] fix: bbc --- docs/en/traditional-media.md | 2 +- docs/traditional-media.md | 2 +- lib/routes/bbc/index.js | 16 +++-- lib/routes/bbc/utils.js | 123 ++++------------------------------- 4 files changed, 27 insertions(+), 116 deletions(-) diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md index 7761174be6..4bdb4c3685 100644 --- a/docs/en/traditional-media.md +++ b/docs/en/traditional-media.md @@ -28,7 +28,7 @@ Site ### BBC - + Provides a better reading experience (full text articles) over the official ones. diff --git a/docs/traditional-media.md b/docs/traditional-media.md index dd1e18cbd8..243e070240 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -34,7 +34,7 @@ pageClass: routes ### BBC 英文 - + 通过提取文章全文,以提供比官方源更佳的阅读体验。 diff --git a/lib/routes/bbc/index.js b/lib/routes/bbc/index.js index 6926b45bc5..5793072533 100644 --- a/lib/routes/bbc/index.js +++ b/lib/routes/bbc/index.js @@ -47,7 +47,7 @@ module.exports = async (ctx) => { } const items = await Promise.all( - feed.items.splice(0, 10).map(async (item) => { + feed.items.splice(0, 30).map(async (item) => { const response = await got({ method: 'get', url: item.link, @@ -58,13 +58,21 @@ module.exports = async (ctx) => { let description; if (response.request.options.url.pathname.startsWith('/news/av')) { - description = utils.ProcessAVFeed($, item.link); + description = item.content; } else { - description = utils.ProcessFeed($, item.link); + description = utils.ProcessFeed($); } + let section = 'sport'; + const urlSplit = item.link.split('/'); + const sectionSplit = urlSplit[urlSplit.length - 1].split('-'); + if (sectionSplit.length > 1) { + section = sectionSplit[0]; + } + section = section[0].toUpperCase() + section.slice(1); + const single = { - title: item.title, + title: `[${section}] ${item.title}`, description, pubDate: item.pubDate, link: item.link, diff --git a/lib/routes/bbc/utils.js b/lib/routes/bbc/utils.js index 8d472fc73c..f1a621fe1a 100644 --- a/lib/routes/bbc/utils.js +++ b/lib/routes/bbc/utils.js @@ -1,83 +1,6 @@ -const cheerio = require('cheerio'); -const ProcessImage = ($, e, c, noscript = false) => { - const img = $(e).find(c); - - if (img.length > 0) { - let message; - // special handling for img wrapped in