From 5b90d88c18ec2110dc347e534daa68f18bddf7bc Mon Sep 17 00:00:00 2001
From: Tim Wu <15276630+TimWu007@users.noreply.github.com>
Date: Thu, 27 Apr 2023 21:55:56 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20NDDaily=20=E5=8D=97?=
=?UTF-8?q?=E6=96=B9=E9=83=BD=E5=B8=82=E6=8A=A5=20(#12370)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): add NDDaily 南方都市报
* fix(route): fix empty pubDate of NDDaily
* fix(route): fix pubDate of NDDaily
* fix(route): rename nddaily to oeeee
* fix(route): rename nddaily to oeeee
---
docs/traditional-media.md | 27 +++++++++++++++++
lib/v2/oeeee/app/channel.js | 36 ++++++++++++++++++++++
lib/v2/oeeee/app/reporter.js | 30 +++++++++++++++++++
lib/v2/oeeee/maintainer.js | 5 ++++
lib/v2/oeeee/radar.js | 12 ++++++++
lib/v2/oeeee/router.js | 5 ++++
lib/v2/oeeee/templates/description.art | 7 +++++
lib/v2/oeeee/utils.js | 41 ++++++++++++++++++++++++++
lib/v2/oeeee/web.js | 36 ++++++++++++++++++++++
9 files changed, 199 insertions(+)
create mode 100644 lib/v2/oeeee/app/channel.js
create mode 100644 lib/v2/oeeee/app/reporter.js
create mode 100644 lib/v2/oeeee/maintainer.js
create mode 100644 lib/v2/oeeee/radar.js
create mode 100644 lib/v2/oeeee/router.js
create mode 100644 lib/v2/oeeee/templates/description.art
create mode 100644 lib/v2/oeeee/utils.js
create mode 100644 lib/v2/oeeee/web.js
diff --git a/docs/traditional-media.md b/docs/traditional-media.md
index 0539455ad..3c6018629 100644
--- a/docs/traditional-media.md
+++ b/docs/traditional-media.md
@@ -1618,6 +1618,33 @@ category 对应的关键词有
+## 南方都市报
+
+### 奥一网
+
+
+
+- 若在桌面端打开奥一网栏目页(如 `OECID`。
+- 若在移动端打开奥一网栏目页(格式例: url 中获取。需注意的是,如果该栏目页的 url 格式为 ,则 `266` 并非为本路由可用的频道 ID,建议从桌面端获取。
+
+
+
+### 南都客户端(按南都号 ID)
+
+
+
+南都号的 UID 可通过 `m.mp.oeeee.com` 下的文章页面获取。点击文章上方的南都号头像,进入该南都号的个人主页,即可从 url 中获取。
+
+
+
+### 南都客户端(按记者)
+
+
+
+记者的 UID 可通过 `m.mp.oeeee.com` 下的文章页面获取。点击文章下方的作者头像,进入该作者的个人主页,即可从 url 中获取。
+
+
+
## 南方网
### 南方 +(按栏目 ID)
diff --git a/lib/v2/oeeee/app/channel.js b/lib/v2/oeeee/app/channel.js
new file mode 100644
index 000000000..d89641333
--- /dev/null
+++ b/lib/v2/oeeee/app/channel.js
@@ -0,0 +1,36 @@
+const got = require('@/utils/got');
+const timezone = require('@/utils/timezone');
+const { parseDate } = require('@/utils/parse-date');
+const { parseArticle } = require('../utils');
+const { art } = require('@/utils/render');
+const path = require('path');
+
+module.exports = async (ctx) => {
+ const id = ctx.params.id ?? 50;
+ const currentUrl = `https://api-ndapp.oeeee.com/friends.php?m=Zone&a=SpaceDoclist&uid=${id}&type=doc`;
+
+ const { data: response } = await got(currentUrl);
+
+ const list = response.data
+ .filter((i) => i.url) // Remove banner and sticky articles.
+ .map((item) => ({
+ title: item.title,
+ description: art(path.join(__dirname, '../templates/description.art'), {
+ thumb: item.titleimg.replace(/\?x-oss-process=.*/g, ''),
+ description: item.summary,
+ }),
+ pubDate: timezone(parseDate(item.ptime * 1000), +8),
+ link: item.url,
+ channel: item.author,
+ }));
+
+ const channel = list[1] ? list[1].channel : '';
+
+ const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+
+ ctx.state.data = {
+ title: `南方都市报客户端 - ${channel}`,
+ link: `https://m.mp.oeeee.com/u/${id}.html`,
+ item: items,
+ };
+};
diff --git a/lib/v2/oeeee/app/reporter.js b/lib/v2/oeeee/app/reporter.js
new file mode 100644
index 000000000..f1d486c24
--- /dev/null
+++ b/lib/v2/oeeee/app/reporter.js
@@ -0,0 +1,30 @@
+const got = require('@/utils/got');
+const { parseArticle } = require('../utils');
+const { art } = require('@/utils/render');
+const path = require('path');
+
+module.exports = async (ctx) => {
+ const id = ctx.params.id ?? 0;
+ const currentUrl = `https://m.mp.oeeee.com/show.php?m=Doc&a=getAuthorInfo&id=${id}`;
+
+ const { data: response } = await got(currentUrl);
+
+ const list = response.data.list.map((item) => ({
+ title: '【' + item.media_nickname + '】' + item.title,
+ description: art(path.join(__dirname, '../templates/description.art'), {
+ thumb: item.titleimg,
+ description: item.summary,
+ }),
+ link: item.url,
+ }));
+
+ const author = response.data.info ? response.data.info.name : '';
+
+ const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+
+ ctx.state.data = {
+ title: `南方都市报奥一网 - ${author}`,
+ link: `https://m.mp.oeeee.com/w/${id}.html`,
+ item: items,
+ };
+};
diff --git a/lib/v2/oeeee/maintainer.js b/lib/v2/oeeee/maintainer.js
new file mode 100644
index 000000000..3092e1bea
--- /dev/null
+++ b/lib/v2/oeeee/maintainer.js
@@ -0,0 +1,5 @@
+module.exports = {
+ '/web/:channel': ['TimWu007'],
+ '/app/channel/:id': ['TimWu007'],
+ '/app/reporter/:id': ['TimWu007'],
+};
diff --git a/lib/v2/oeeee/radar.js b/lib/v2/oeeee/radar.js
new file mode 100644
index 000000000..d354fac77
--- /dev/null
+++ b/lib/v2/oeeee/radar.js
@@ -0,0 +1,12 @@
+module.exports = {
+ 'oeeee.com': {
+ _name: '奥一网',
+ '.': [
+ {
+ title: '新闻',
+ docs: 'https://docs.rsshub.app/traditional-media.html#nan-fang-du-shi-bao',
+ source: ['/'],
+ },
+ ],
+ },
+};
diff --git a/lib/v2/oeeee/router.js b/lib/v2/oeeee/router.js
new file mode 100644
index 000000000..f6275347d
--- /dev/null
+++ b/lib/v2/oeeee/router.js
@@ -0,0 +1,5 @@
+module.exports = (router) => {
+ router.get('/web/:channel', require('./web'));
+ router.get('/app/channel/:id', require('./app/channel'));
+ router.get('/app/reporter/:id', require('./app/reporter'));
+};
diff --git a/lib/v2/oeeee/templates/description.art b/lib/v2/oeeee/templates/description.art
new file mode 100644
index 000000000..8768b47a5
--- /dev/null
+++ b/lib/v2/oeeee/templates/description.art
@@ -0,0 +1,7 @@
+{{ if thumb }}
+
+{{ /if }}
+{{ if description }}
+
{{ description }}
+
+{{ /if }}
\ No newline at end of file
diff --git a/lib/v2/oeeee/utils.js b/lib/v2/oeeee/utils.js
new file mode 100644
index 000000000..a5a66d4ae
--- /dev/null
+++ b/lib/v2/oeeee/utils.js
@@ -0,0 +1,41 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const timezone = require('@/utils/timezone');
+const { parseDate } = require('@/utils/parse-date');
+
+const parseArticle = (item, tryGet) =>
+ tryGet(item.link, async () => {
+ const detailResponse = await got({
+ method: 'get',
+ url: item.link,
+ });
+
+ const content = cheerio.load(detailResponse.data);
+
+ // nfapp page:
+ if (content('.post-cont') && content('.post-cont').html()) {
+ content('img').removeAttr('data-width').removeAttr('data-height').removeAttr('class').removeAttr('title').removeAttr('referrerpolicy');
+ content('.taglist, .J_ndlogo, .zan-shang, .sourcelist-box, #shareContain, .buyCopyright, .article-info, .icon, .special').remove();
+ item.description +=
+ content('.post-cont')
+ .html()
+ .replace(/data:image\S*=="\s*\n*\s*original="/g, '') ?? '';
+ if (!item.pubDate) {
+ item.pubDate = timezone(parseDate(content('.introduce').text().split()), +8);
+ }
+ }
+ // oeeee news page:
+ else if (content('.content') && content('.content').html()) {
+ item.description += content('.content').html() ?? '';
+ }
+ // oeeee news page #2:
+ else if (content('.article-conten') && content('.article-conten').html()) {
+ item.description += content('.article-conten').html() ?? '';
+ }
+
+ return item;
+ });
+
+module.exports = {
+ parseArticle,
+};
diff --git a/lib/v2/oeeee/web.js b/lib/v2/oeeee/web.js
new file mode 100644
index 000000000..3bc8ecd61
--- /dev/null
+++ b/lib/v2/oeeee/web.js
@@ -0,0 +1,36 @@
+const got = require('@/utils/got');
+const timezone = require('@/utils/timezone');
+const { parseDate } = require('@/utils/parse-date');
+const { parseArticle } = require('./utils');
+const { art } = require('@/utils/render');
+const path = require('path');
+
+module.exports = async (ctx) => {
+ const channel = ctx.params.channel ?? 0;
+ const currentUrl = `https://www.oeeee.com/api/channel.php?m=Js4channelNews&a=newLatest&cid=${channel}`;
+
+ const { data: response } = await got(currentUrl);
+
+ const list = response.data.map((item) => ({
+ title: '【' + item.channel_name + '】' + item.title,
+ description: art(path.join(__dirname, 'templates/description.art'), {
+ thumb: item.img,
+ description: item.summary,
+ }),
+ pubDate: timezone(parseDate(item.datetime), +8),
+ link: item.linkurl,
+ author: item.author,
+ // channelName: item.channel_name,
+ channelEname: item.channel_ename,
+ }));
+
+ const channelEname = list[1] ? list[1].channelEname : '';
+
+ const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+
+ ctx.state.data = {
+ title: `南方都市报奥一网`,
+ link: `https://www.oeeee.com/api/channel.php?s=/index/index/channel/${channelEname}`,
+ item: items,
+ };
+};