feat(route): add 网易独家栏目 (#10099)
This commit is contained in:
parent
9d26801d1f
commit
ec7bf02b4a
|
|
@ -3384,6 +3384,33 @@ column 为 third 时可选的 category:
|
|||
|
||||
</Route>
|
||||
|
||||
## 网易独家
|
||||
|
||||
### 栏目
|
||||
|
||||
<Route author="nczitzk" example="/netease/exclusive/qsyk" path="/netease/exclusive/:id?" :paramsDesc="['栏目, 默认为首页']">
|
||||
|
||||
| 分类 | 编号 |
|
||||
| ---- | ---- |
|
||||
| 首页 | |
|
||||
| 轻松一刻 | qsyk |
|
||||
| 槽值 | cz |
|
||||
| 人间 | rj |
|
||||
| 大国小民 | dgxm |
|
||||
| 三三有梗 | ssyg |
|
||||
| 数读 | sd |
|
||||
| 看客 | kk |
|
||||
| 下划线 | xhx |
|
||||
| 谈心社 | txs |
|
||||
| 哒哒 | dd |
|
||||
| 胖编怪聊 | pbgl |
|
||||
| 曲一刀 | qyd |
|
||||
| 今日之声 | jrzs |
|
||||
| 浪潮 | lc |
|
||||
| 沸点 | fd |
|
||||
|
||||
</Route>
|
||||
|
||||
## 网易号
|
||||
|
||||
### 更新
|
||||
|
|
|
|||
|
|
@ -0,0 +1,148 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
const ids = {
|
||||
'': {
|
||||
id: 'BAI5E21O',
|
||||
title: '首页',
|
||||
},
|
||||
qsyk: {
|
||||
id: 'BD21K0DL',
|
||||
title: '轻松一刻',
|
||||
},
|
||||
cz: {
|
||||
id: 'CICMICLU',
|
||||
title: '槽值',
|
||||
},
|
||||
rj: {
|
||||
id: 'CICMOMBL',
|
||||
title: '人间',
|
||||
},
|
||||
dgxm: {
|
||||
id: 'CICMPVC5',
|
||||
title: '大国小民',
|
||||
},
|
||||
ssyg: {
|
||||
id: 'CICMLCOU',
|
||||
title: '三三有梗',
|
||||
},
|
||||
sd: {
|
||||
id: 'D551V75C',
|
||||
title: '数读',
|
||||
},
|
||||
kk: {
|
||||
id: 'D55253RH',
|
||||
title: '看客',
|
||||
},
|
||||
xhx: {
|
||||
id: 'D553A53L',
|
||||
title: '下划线',
|
||||
},
|
||||
txs: {
|
||||
id: 'D553PGHQ',
|
||||
title: '谈心社',
|
||||
},
|
||||
dd: {
|
||||
id: 'CICMS5BI',
|
||||
title: '哒哒',
|
||||
},
|
||||
pbgl: {
|
||||
id: 'CQ9UDVKO',
|
||||
title: '胖编怪聊',
|
||||
},
|
||||
qyd: {
|
||||
id: 'CQ9UJIJN',
|
||||
title: '曲一刀',
|
||||
},
|
||||
jrzs: {
|
||||
id: 'BD284UM8',
|
||||
title: '今日之声',
|
||||
},
|
||||
lc: {
|
||||
id: 'CICMMGBH',
|
||||
title: '浪潮',
|
||||
},
|
||||
fd: {
|
||||
id: 'D5543R68',
|
||||
title: '沸点',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '';
|
||||
|
||||
const rootUrl = 'https://3g.163.com';
|
||||
const currentUrl = `${rootUrl}/touch/exclusive${id ? `/sub/${id}` : ''}`;
|
||||
const apiUrl = `${rootUrl}/touch/reconstruct/article/list/${ids[id].id}wangning/0-20.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
const data = JSON.parse(response.data.match(/^artiList\((.*)\)$/)[1])[`${ids[id].id}wangning`];
|
||||
|
||||
let items = data.map((item) => ({
|
||||
title: item.title,
|
||||
author: item.source,
|
||||
link: item.skipURL || item.url || `${rootUrl}/dy/article/${item.docid}.html`,
|
||||
pubDate: timezone(parseDate(item.ptime), +8),
|
||||
videoId: item.skipType === 'video' ? item.stitle : '',
|
||||
}));
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
try {
|
||||
if (item.videoId) {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: `${rootUrl}/touch/video/detail/jsonp/VIA8K0PTB.html?callback=videoList`,
|
||||
});
|
||||
|
||||
const video = JSON.parse(detailResponse.data.match(/^videoList\((.*)\)$/)[1])?.mp4_url;
|
||||
|
||||
item.description = art(path.join(__dirname, 'templates/exclusive.art'), {
|
||||
video,
|
||||
});
|
||||
} else {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.m-linkCard').remove();
|
||||
|
||||
content('.m-photo').each(function () {
|
||||
content(this).html(
|
||||
art(path.join(__dirname, 'templates/exclusive.art'), {
|
||||
image: content(this).find('img').attr('data-src'),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
item.description = content('.article-body').html();
|
||||
}
|
||||
} catch (e) {
|
||||
// no-empty
|
||||
}
|
||||
|
||||
delete item.videoId;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `网易独家 - ${ids[id].title}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = {
|
||||
'/exclusive/:id?': ['nczitzk'],
|
||||
'/renjian/:category?': ['nczitzk'],
|
||||
'/today/:need_content?': ['nczitzk'],
|
||||
'/news/rank/:category?/:type?/:time?': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
module.exports = {
|
||||
'163.com': {
|
||||
_name: '网易',
|
||||
'': [
|
||||
{
|
||||
title: '独家栏目',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#wang-yi-du-jia-lan-mu',
|
||||
source: ['/'],
|
||||
target: '/netease/exclusive/:id?',
|
||||
},
|
||||
],
|
||||
renjian: [
|
||||
{
|
||||
title: '人间',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/exclusive/:id?', require('./exclusive'));
|
||||
router.get('/renjian/:category?', require('./renjian'));
|
||||
router.get('/today/:need_content?', require('./today'));
|
||||
router.get('/news/rank/:category?/:type?/:time?', require('./rank'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
{{ if image }}
|
||||
<img src="{{ image }}">
|
||||
{{ /if }}
|
||||
{{ if video }}
|
||||
<video controls>
|
||||
<source src="{{ video }}" type="video/mp4">
|
||||
</video>
|
||||
{{ /if }}
|
||||
{{ if digest }}
|
||||
<p>{{ digest }}</p>
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue