diff --git a/docs/traditional-media.md b/docs/traditional-media.md index c24304002..8d4d1ad91 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1186,7 +1186,7 @@ category 对应的关键词有 ### 频道 - + | 视频 | 时事 | 财经 | 思想 | 澎湃号 | 生活 | | ----- | ----- | ----- | ----- | ----- | ----- | @@ -1198,6 +1198,10 @@ category 对应的关键词有 +### 明查 + + + ### 澎湃美数组作品集 diff --git a/lib/router.js b/lib/router.js index 14036b2bf..2841f0d7d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -848,13 +848,13 @@ router.get('/xclient/app/:name', lazyloadRouteHandler('./routes/xclient/app')); router.get('/embassy/:country/:city?', lazyloadRouteHandler('./routes/embassy/index')); // 澎湃新闻 -router.get('/thepaper/featured', lazyloadRouteHandler('./routes/thepaper/featured')); -router.get('/thepaper/channel/:id', lazyloadRouteHandler('./routes/thepaper/channel')); -router.get('/thepaper/list/:id', lazyloadRouteHandler('./routes/thepaper/list')); +// router.get('/thepaper/featured', lazyloadRouteHandler('./routes/thepaper/featured')); +// router.get('/thepaper/channel/:id', lazyloadRouteHandler('./routes/thepaper/channel')); +// router.get('/thepaper/list/:id', lazyloadRouteHandler('./routes/thepaper/list')); // 澎湃美数课 -router.get('/thepaper/839studio', lazyloadRouteHandler('./routes/thepaper/839studio/studio.js')); -router.get('/thepaper/839studio/:id', lazyloadRouteHandler('./routes/thepaper/839studio/category.js')); +// router.get('/thepaper/839studio', lazyloadRouteHandler('./routes/thepaper/839studio/studio.js')); +// router.get('/thepaper/839studio/:id', lazyloadRouteHandler('./routes/thepaper/839studio/category.js')); // 电影首发站 router.get('/dysfz', lazyloadRouteHandler('./routes/dysfz/index')); diff --git a/lib/routes/thepaper/utils.js b/lib/routes/thepaper/utils.js deleted file mode 100644 index 772f1ae6b..000000000 --- a/lib/routes/thepaper/utils.js +++ /dev/null @@ -1,48 +0,0 @@ -const cheerio = require('cheerio'); -const date = require('@/utils/date'); -const got = require('@/utils/got'); - -module.exports = { - ProcessFeed: async (query, link, ctx) => { - const res = await got.get(link); - - const $ = cheerio.load(res.data); - const list = $(query).slice(0, 10).get(); - - return Promise.all( - list.map(async (item) => { - const $ = cheerio.load(item); - const itemUrl = `https://m.thepaper.cn/${$(item).find('a').eq(0).attr('href')}`; - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const res = await got.get(itemUrl); - const content = cheerio.load(res.data); - - let description, pubDate; - - if (content('div.news_video_msg').length > 0) { - description = content('#vdetail_sum').html(); - pubDate = content('div.news_video_msg').html().split('  ')[0]; - } else if (content('#slider_wrapper_ul').length > 0) { - description = ''; - pubDate = new Date(date($(item).find('div.list_item_extra span').eq(1).text())).toUTCString(); - } else { - description = content('div.newsdetail_content').html(); - pubDate = new Date(content('div.date').text().trim().split('来源:')[0].trim() + ' GMT+8').toUTCString(); - } - - const single = { - title: content('title').text(), - link: itemUrl, - description, - pubDate, - author: content('div.author').text(), - }; - return Promise.resolve(single); - }) - ); - }, -}; diff --git a/lib/routes/thepaper/839studio/category.js b/lib/v2/thepaper/839studio/category.js similarity index 100% rename from lib/routes/thepaper/839studio/category.js rename to lib/v2/thepaper/839studio/category.js diff --git a/lib/routes/thepaper/839studio/studio.js b/lib/v2/thepaper/839studio/studio.js similarity index 100% rename from lib/routes/thepaper/839studio/studio.js rename to lib/v2/thepaper/839studio/studio.js diff --git a/lib/routes/thepaper/channel.js b/lib/v2/thepaper/channel.js similarity index 100% rename from lib/routes/thepaper/channel.js rename to lib/v2/thepaper/channel.js diff --git a/lib/v2/thepaper/factpaper.js b/lib/v2/thepaper/factpaper.js new file mode 100644 index 000000000..23158b8a6 --- /dev/null +++ b/lib/v2/thepaper/factpaper.js @@ -0,0 +1,61 @@ +const got = require('@/utils/got'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const status = parseInt(ctx.params.status ?? '1'); + + const rootUrl = 'https://www.factpaper.cn'; + const apiRootUrl = 'https://api.factpaper.cn'; + const currentUrl = `${apiRootUrl}/fact-check/front/proveList`; + + const response = await got({ + method: 'post', + url: currentUrl, + json: { + pageNum: 1, + pageSize: 20, + status, + }, + }); + + let items = response.data.data.list.map((item) => ({ + title: item.title, + guid: item.proveId, + link: `${rootUrl}/detail?id=${item.proveId}`, + pubDate: timezone(parseDate(item.publishTime), +8), + })); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'post', + url: `${apiRootUrl}/fact-check/front/proveInfo`, + json: { + proveId: item.guid, + }, + }); + + const data = detailResponse.data.data; + + item.author = data.userName; + item.description = art(path.join(__dirname, 'templates/factpaper.art'), { + content: data.content, + checkinfo: data.checkInfoList, + finalCheckInfo: data.finalCheckInfo, + }); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `澎湃明查 - ${status === 1 ? '有定论' : '核查中'}`, + link: rootUrl, + item: items, + }; +}; diff --git a/lib/routes/thepaper/featured.js b/lib/v2/thepaper/featured.js similarity index 100% rename from lib/routes/thepaper/featured.js rename to lib/v2/thepaper/featured.js diff --git a/lib/routes/thepaper/list.js b/lib/v2/thepaper/list.js similarity index 100% rename from lib/routes/thepaper/list.js rename to lib/v2/thepaper/list.js diff --git a/lib/v2/thepaper/maintainer.js b/lib/v2/thepaper/maintainer.js new file mode 100644 index 000000000..b34875780 --- /dev/null +++ b/lib/v2/thepaper/maintainer.js @@ -0,0 +1,8 @@ +module.exports = { + '/839studio/:id': ['umm233'], + '/839studio': ['umm233'], + '/channel/:id': ['xyqfer', 'nczitzk'], + '/featured': ['HenryQW', 'nczitzk'], + '/factpaper/:status?': ['nczitzk'], + '/list/:id': ['nczitzk'], +}; diff --git a/lib/v2/thepaper/radar.js b/lib/v2/thepaper/radar.js new file mode 100644 index 000000000..42cf1c2c2 --- /dev/null +++ b/lib/v2/thepaper/radar.js @@ -0,0 +1,42 @@ +module.exports = { + 'thepaper.cn': { + _name: '澎湃新闻', + '.': [ + { + title: '首页头条', + docs: 'https://docs.rsshub.app/traditional-media.html#peng-pai-xin-wen-shou-ye-tou-tiao', + source: ['/'], + target: '/thepaper/featured', + }, + { + title: '频道', + docs: 'https://docs.rsshub.app/traditional-media.html#peng-pai-xin-wen-pin-dao', + source: ['/'], + target: (params, url) => `/thepaper/channel/${new URL(url).search(/channel_(\d+)/)}`, + }, + { + title: '列表', + docs: 'https://docs.rsshub.app/traditional-media.html#peng-pai-xin-wen-lie-biao', + source: ['/'], + target: (params, url) => `/thepaper/channel/${new URL(url).search(/list_(\d+)/)}`, + }, + { + title: '澎湃美数组作品集', + docs: 'https://docs.rsshub.app/traditional-media.html#peng-pai-xin-wen-peng-pai-mei-shu-zuo-pin-ji', + source: ['/'], + target: '/thepaper/839studio/:id', + }, + ], + }, + 'factpaper.cn': { + _name: '澎湃新闻', + '.': [ + { + title: '明查', + docs: 'https://docs.rsshub.app/traditional-media.html#peng-pai-xin-wen-ming-cha', + source: ['/'], + target: '/thepaper/factpaper/:status', + }, + ], + }, +}; diff --git a/lib/v2/thepaper/router.js b/lib/v2/thepaper/router.js new file mode 100644 index 000000000..be6f7685d --- /dev/null +++ b/lib/v2/thepaper/router.js @@ -0,0 +1,8 @@ +module.exports = function (router) { + router.get('/839studio', require('./839studio/studio')); + router.get('/839studio/:id', require('./839studio/category')); + router.get('/channel/:id', require('./channel')); + router.get('/featured', require('./featured')); + router.get('/factpaper/:status?', require('./factpaper')); + router.get('/list/:id', require('./list')); +}; diff --git a/lib/v2/thepaper/templates/factpaper.art b/lib/v2/thepaper/templates/factpaper.art new file mode 100644 index 000000000..c78a15da3 --- /dev/null +++ b/lib/v2/thepaper/templates/factpaper.art @@ -0,0 +1,12 @@ +

发起求证

+{{@ content }} +{{if checkinfo}} +

一起核查

+{{each checkinfo check}} +{{@ check.content }} +{{/each}} +{{/if}} +{{if finalCheckInfo}} +

有定论了

+{{@ finalCheckInfo.content }} +{{/if}} \ No newline at end of file diff --git a/lib/v2/thepaper/utils.js b/lib/v2/thepaper/utils.js new file mode 100644 index 000000000..29850b582 --- /dev/null +++ b/lib/v2/thepaper/utils.js @@ -0,0 +1,55 @@ +const cheerio = require('cheerio'); +const date = require('@/utils/date'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const got = require('@/utils/got'); + +module.exports = { + ProcessFeed: async (query, link, ctx) => { + const res = await got(link); + + const $ = cheerio.load(res.data); + const list = $(query).slice(0, 10).get(); + + return Promise.all( + list.map((item) => { + const $ = cheerio.load(item); + const itemUrl = `https://m.thepaper.cn/${$(item).find('a').eq(0).attr('href')}`; + return ctx.cache.tryGet(itemUrl, async () => { + const res = await got(itemUrl); + const content = cheerio.load(res.data); + + let description, pubDate; + + if (content('div.news_video_msg').length > 0) { + description = content('#vdetail_sum').html(); + pubDate = timezone( + parseDate( + content('div.news_video_msg') + .html() + .replace(/ /gi, '') + .split('
')[0] + ), + +8 + ); + } else if (content('#slider_wrapper_ul').length > 0) { + description = ''; + pubDate = new Date(date($(item).find('div.list_item_extra span').eq(1).text())).toUTCString(); + } else { + description = content('div.newsdetail_content').html(); + pubDate = timezone(parseDate(content('div.date').text().trim().split('来源:')[0].trim()), +8); + } + + const single = { + title: content('title').text(), + link: itemUrl, + description, + pubDate, + author: content('div.author').text(), + }; + return single; + }); + }) + ); + }, +};