Skip to content

Commit

Permalink
fix(route): 腾讯企鹅号正文乱码 (DIYgod#12130)
Browse files Browse the repository at this point in the history
  • Loading branch information
miles170 authored Mar 17, 2023
1 parent 86d10ae commit 00c01d9
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 63 deletions.
2 changes: 1 addition & 1 deletion docs/new-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -3758,7 +3758,7 @@ column 为 third 时可选的 category:

### 更新

<Route author="LogicJake" example="/tencent/news/author/5933889" path="/tencent/news/author/:mid" :paramsDesc="['企鹅号 ID']"/>
<Route author="LogicJake" example="/tencent/news/author/5933889" path="/tencent/news/author/:mid" :paramsDesc="['企鹅号 ID']" radar="1"/>

## 腾讯研究院

Expand Down
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
59 changes: 0 additions & 59 deletions lib/routes/tencent/news/author.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/v2/tencent/maintainer.js
Original file line number Diff line number Diff line change
@@ -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'],
Expand Down
44 changes: 44 additions & 0 deletions lib/v2/tencent/news/author.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
8 changes: 7 additions & 1 deletion lib/v2/tencent/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lib/v2/tencent/router.js
Original file line number Diff line number Diff line change
@@ -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'));
Expand Down

0 comments on commit 00c01d9

Please sign in to comment.