From 716f59e903c9cecd16a39bec21608bde577cb890 Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Wed, 24 Jan 2024 02:35:08 +0800 Subject: [PATCH] fix(route/tencent): Circumvent video type link. (#14302) * fix(route/tencent): Circumvent video type link. * . --- lib/v2/tencent/news/author.js | 60 ++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/lib/v2/tencent/news/author.js b/lib/v2/tencent/news/author.js index 1b025a8ded..290fbf6a0c 100644 --- a/lib/v2/tencent/news/author.js +++ b/lib/v2/tencent/news/author.js @@ -24,34 +24,42 @@ module.exports = async (ctx) => { const author = item.source; const abstract = item.abstract; - return ctx.cache.tryGet(itemUrl, async () => { - const response = await got(itemUrl); - const $ = cheerio.load(response.data); - const data = JSON.parse( - $('script:contains("window.DATA")') - .text() - .match(/window\.DATA = ({.+});/)[1] - ); - const $data = cheerio.load(data.originContent.text, null, false); + return item.articletype === '4' + ? { + title, + description: abstract, + link: itemUrl, + author, + pubDate, + } + : ctx.cache.tryGet(itemUrl, async () => { + const response = await got(itemUrl); + const $ = cheerio.load(response.data); + const data = JSON.parse( + $('script:contains("window.DATA")') + .text() + .match(/window\.DATA = ({.+});/)[1] + ); + const $data = cheerio.load(data.originContent.text, null, false); - $data('*') - .contents() - .filter((_, elem) => elem.type === 'comment') - .replaceWith((_, elem) => - art(path.join(__dirname, '../templates/news/image.art'), { - attribute: elem.data.trim(), - originAttribute: data.originAttribute, - }) - ); + $data('*') + .contents() + .filter((_, elem) => elem.type === 'comment') + .replaceWith((_, elem) => + art(path.join(__dirname, '../templates/news/image.art'), { + attribute: elem.data.trim(), + originAttribute: data.originAttribute, + }) + ); - return { - title, - description: $data.html() || abstract, - link: itemUrl, - author, - pubDate, - }; - }); + return { + title, + description: $data.html() || abstract, + link: itemUrl, + author, + pubDate, + }; + }); }) );