diff --git a/docs/new-media.md b/docs/new-media.md index 577ac5537..1e7db3d58 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3384,6 +3384,33 @@ column 为 third 时可选的 category: +## 网易独家 + +### 栏目 + + + +| 分类 | 编号 | +| ---- | ---- | +| 首页 | | +| 轻松一刻 | qsyk | +| 槽值 | cz | +| 人间 | rj | +| 大国小民 | dgxm | +| 三三有梗 | ssyg | +| 数读 | sd | +| 看客 | kk | +| 下划线 | xhx | +| 谈心社 | txs | +| 哒哒 | dd | +| 胖编怪聊 | pbgl | +| 曲一刀 | qyd | +| 今日之声 | jrzs | +| 浪潮 | lc | +| 沸点 | fd | + + + ## 网易号 ### 更新 diff --git a/lib/v2/netease/exclusive.js b/lib/v2/netease/exclusive.js new file mode 100644 index 000000000..79e426400 --- /dev/null +++ b/lib/v2/netease/exclusive.js @@ -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, + }; +}; diff --git a/lib/v2/netease/maintainer.js b/lib/v2/netease/maintainer.js index 20f63d2be..8b73669a8 100644 --- a/lib/v2/netease/maintainer.js +++ b/lib/v2/netease/maintainer.js @@ -1,4 +1,5 @@ module.exports = { + '/exclusive/:id?': ['nczitzk'], '/renjian/:category?': ['nczitzk'], '/today/:need_content?': ['nczitzk'], '/news/rank/:category?/:type?/:time?': ['nczitzk'], diff --git a/lib/v2/netease/radar.js b/lib/v2/netease/radar.js index b55de86c3..41ea928b5 100644 --- a/lib/v2/netease/radar.js +++ b/lib/v2/netease/radar.js @@ -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: '人间', diff --git a/lib/v2/netease/router.js b/lib/v2/netease/router.js index 8ee121e68..f93652a8c 100644 --- a/lib/v2/netease/router.js +++ b/lib/v2/netease/router.js @@ -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')); diff --git a/lib/v2/netease/templates/exclusive.art b/lib/v2/netease/templates/exclusive.art new file mode 100644 index 000000000..ffe6b432c --- /dev/null +++ b/lib/v2/netease/templates/exclusive.art @@ -0,0 +1,11 @@ +{{ if image }} + +{{ /if }} +{{ if video }} + +{{ /if }} +{{ if digest }} +

{{ digest }}

+{{ /if }} \ No newline at end of file