<\\/a>'))[1].split('"')[0]}`;
+
const currentResponse = await got({
method: 'get',
url: currentUrl,
@@ -23,24 +27,26 @@ module.exports = async (ctx) => {
const $ = cheerio.load(currentResponse.data);
- const list = $('.pro-info p a')
- .slice(0, 10)
- .map((_, item) => {
+ let items = $('.pro-info p a')
+ .toArray()
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10)
+ .map((item) => {
item = $(item);
+
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
};
- })
- .get();
+ });
- const items = await Promise.all(
- list.map((item) =>
+ items = await Promise.all(
+ items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
+
const content = cheerio.load(detailResponse.data);
content('.more-bt').remove();
@@ -53,7 +59,7 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
- title: `得到 - ${caty}`,
+ title: `得到 - ${category}`,
link: currentUrl,
item: items,
};
diff --git a/lib/v2/dedao/maintainer.js b/lib/v2/dedao/maintainer.js
new file mode 100644
index 000000000..57bfb1b03
--- /dev/null
+++ b/lib/v2/dedao/maintainer.js
@@ -0,0 +1,8 @@
+module.exports = {
+ '/figure': ['nczitzk'],
+ '/knowledge/:topic?/:type?': ['nczitzk'],
+ '/list/:category?': ['nczitzk'],
+ '/news': ['nczitzk'],
+ '/user/:id/:type?': ['nczitzk'],
+ '/video': ['nczitzk'],
+};
diff --git a/lib/v2/dedao/radar.js b/lib/v2/dedao/radar.js
new file mode 100644
index 000000000..f7c491827
--- /dev/null
+++ b/lib/v2/dedao/radar.js
@@ -0,0 +1,50 @@
+module.exports = {
+ 'dedao.cn': {
+ _name: '得到',
+ '.': [
+ {
+ title: '知识城邦',
+ docs: 'https://docs.rsshub.app/new-media.html#de-dao-zhi-shi-cheng-bang',
+ source: ['/knowledge/topic/:topic', '/knowledge', '/'],
+ target: '/dedao/knowledge/:topic?/:type?',
+ },
+ ],
+ },
+ 'igetget.com': {
+ _name: '得到',
+ '.': [
+ {
+ title: '首页',
+ docs: 'https://docs.rsshub.app/new-media.html#de-dao-shou-ye',
+ source: ['/'],
+ target: '/dedao/list/:category?',
+ },
+ {
+ title: '新闻',
+ docs: 'https://docs.rsshub.app/new-media.html#de-dao-xin-wen',
+ source: ['/news', '/'],
+ target: '/dedao/news',
+ },
+ {
+ title: '人物故事',
+ docs: 'https://docs.rsshub.app/new-media.html#de-dao-ren-wu-gu-shi',
+ source: ['/news', '/'],
+ target: '/dedao/figure',
+ },
+ {
+ title: '视频',
+ docs: 'https://docs.rsshub.app/new-media.html#de-dao-shi-pin',
+ source: ['/video', '/'],
+ target: '/dedao/video',
+ },
+ ],
+ m: [
+ {
+ title: '用户主页',
+ docs: 'https://docs.rsshub.app/new-media.html#de-dao-yong-hu-zhu-ye',
+ source: ['/native/mine/account', '/'],
+ target: (params, url) => `/dedao/user/${new URL(url).searchParams.get('enId')}`,
+ },
+ ],
+ },
+};
diff --git a/lib/v2/dedao/router.js b/lib/v2/dedao/router.js
new file mode 100644
index 000000000..095937907
--- /dev/null
+++ b/lib/v2/dedao/router.js
@@ -0,0 +1,6 @@
+module.exports = function (router) {
+ router.get('/knowledge/:topic?/:type?', require('./knowledge'));
+ router.get('/list/:category?', require('./list'));
+ router.get('/user/:id/:type?', require('./user'));
+ router.get('/:category?', require('./index'));
+};
diff --git a/lib/v2/dedao/templates/knowledge.art b/lib/v2/dedao/templates/knowledge.art
new file mode 100644
index 000000000..fe5facf22
--- /dev/null
+++ b/lib/v2/dedao/templates/knowledge.art
@@ -0,0 +1,29 @@
+{{ if f_part.note }}
+{{@ f_part.note
+ .replace(/\n\n/g, '
')
+ .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1')
+ }}
+{{ /if }}
+{{ if f_part.images }}
+
+{{ set f_part_images = f_part.images }}
+{{ each f_part_images image }}
+
+{{ /each }}
+{{ /if }}
+{{ if s_part }}
+
+引用 {{ s_part.nick_name }}{{ if s_part.v_info }} ({{ s_part.v_info }}){{ /if }}:
+{{@ s_part.note
+ .replace(/\n\n/g, '
')
+ .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1')
+ }}
+')
+ .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1')
+ }}
+')
+ .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1')
+ }}
+{{ if extra }}
+