diff --git a/docs/new-media.md b/docs/new-media.md index a1d109e8094999..033fce2e23557e 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3758,7 +3758,7 @@ column 为 third 时可选的 category: ### 更新 - + ## 腾讯研究院 diff --git a/lib/router.js b/lib/router.js index f598e63e7a0f8d..6259302fec6f56 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2044,8 +2044,8 @@ router.get('/nciae/xsxx', lazyloadRouteHandler('./routes/universities/nciae/xsxx // cfan router.get('/cfan/news', lazyloadRouteHandler('./routes/cfan/news')); -// 腾讯企鹅号 -router.get('/tencent/news/author/:mid', lazyloadRouteHandler('./routes/tencent/news/author')); +// 腾讯企鹅号 migrated to v2 +// router.get('/tencent/news/author/:mid', lazyloadRouteHandler('./routes/tencent/news/author')); // 奈菲影视 router.get('/nfmovies/:id?', lazyloadRouteHandler('./routes/nfmovies/index')); diff --git a/lib/routes/tencent/news/author.js b/lib/routes/tencent/news/author.js deleted file mode 100644 index d779ef5a5bde42..00000000000000 --- a/lib/routes/tencent/news/author.js +++ /dev/null @@ -1,59 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const date = require('@/utils/date'); -const iconv = require('iconv-lite'); - -module.exports = async (ctx) => { - const mid = ctx.params.mid; - const link = `https://new.qq.com/omn/author/${mid}`; - const api_url = `https://pacaio.match.qq.com/om/mediaArticles?mid=${mid}&num=15&page=0`; - const response = await got({ - method: 'get', - url: api_url, - headers: { Referer: link }, - }); - const reponse = response.data; - const title = reponse.mediainfo.name; - const description = reponse.mediainfo.intro; - const list = reponse.data.splice(0, 10); - - const items = await Promise.all( - list.map(async (item) => { - const title = item.title; - const unixTimestamp = new Date(item.timestamp * 1000); - const pubDate = date(unixTimestamp.toLocaleString(), 8); - const itemUrl = item.vurl; - const author = item.source; - const abstract = item.abstract; - - const response = await ctx.cache.tryGet( - itemUrl, - async () => - ( - await got.get(itemUrl, { - responseType: 'buffer', - }) - ).data - ); - const html = iconv.decode(response, 'gbk'); - const $ = cheerio.load(html, { decodeEntities: false }); - const article = $('div.content-article'); - - const single = { - title, - description: article.html() || abstract, - link: itemUrl, - author, - pubDate, - }; - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title, - description, - link, - item: items, - }; -}; diff --git a/lib/v2/tencent/maintainer.js b/lib/v2/tencent/maintainer.js index 6fa25e9c216e4e..ea5271f5c4224d 100644 --- a/lib/v2/tencent/maintainer.js +++ b/lib/v2/tencent/maintainer.js @@ -1,5 +1,6 @@ module.exports = { '/cloud/column/:id?/:tag?': ['nczitzk'], + '/news/author/:mid': ['LogicJake', 'miles170'], '/news/coronavirus/data/:province?/:city?': ['CaoMeiYouRen'], '/news/coronavirus/total': ['CaoMeiYouRen'], '/pvp/newsindex/:type': ['Jeason0228', 'HenryQW'], diff --git a/lib/v2/tencent/news/author.js b/lib/v2/tencent/news/author.js new file mode 100644 index 00000000000000..5d473a85f28b28 --- /dev/null +++ b/lib/v2/tencent/news/author.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const mid = ctx.params.mid; + const response = await got(`https://pacaio.match.qq.com/om/mediaArticles?mid=${mid}&num=10&page=0`); + const reponse = response.data; + const title = reponse.mediainfo.name; + const description = reponse.mediainfo.intro; + const list = reponse.data; + + const items = await Promise.all( + list.map((item) => { + const title = item.title; + const pubDate = timezone(parseDate(item.time), +8); + const itemUrl = item.vurl; + 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 article = $('div.content-article'); + + return { + title, + description: article.html() || abstract, + link: itemUrl, + author, + pubDate, + }; + }); + }) + ); + + ctx.state.data = { + title, + description, + link: `https://new.qq.com/omn/author/${mid}`, + item: items, + }; +}; diff --git a/lib/v2/tencent/radar.js b/lib/v2/tencent/radar.js index 6fd8cab0e61e05..b68e2ddee7fae1 100644 --- a/lib/v2/tencent/radar.js +++ b/lib/v2/tencent/radar.js @@ -27,7 +27,13 @@ module.exports = { target: (params, url) => `/wechat/mp/msgalbum/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('album_id')}`, }, ], - news: [ + new: [ + { + title: '腾讯企鹅号 - 更新', + docs: 'https://docs.rsshub.app/new-media.html#teng-xun-qi-e-hao-geng-xin', + source: ['/omn/author/:mid'], + target: '/tencent/news/author/:mid', + }, { title: '腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪', docs: 'https://docs.rsshub.app/other.html#xin-guan-fei-yan-yi-qing-xin-wen-dong-tai', diff --git a/lib/v2/tencent/router.js b/lib/v2/tencent/router.js index cec464ac118469..560eca80149c7e 100644 --- a/lib/v2/tencent/router.js +++ b/lib/v2/tencent/router.js @@ -1,5 +1,6 @@ module.exports = (router) => { router.get('/cloud/column/:id?/:tag?', require('./cloud/column')); + router.get('/news/author/:mid', require('./news/author')); router.get('/news/coronavirus/data/:province?/:city?', require('./news/coronavirus/data')); router.get('/news/coronavirus/total', require('./news/coronavirus/total')); router.get('/pvp/newsindex/:type', require('./pvp/newsindex'));