rsshub 1.0.0-master.cf674e2 → 1.0.0-master.cf6dff4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/router.js CHANGED
@@ -3095,8 +3095,8 @@ router.get('/3k8/latest', lazyloadRouteHandler('./routes/3k8/latest'));
3095
3095
  // JustRun
3096
3096
  router.get('/justrun', lazyloadRouteHandler('./routes/justrun/index'));
3097
3097
 
3098
- // 上海电力大学
3099
- router.get('/shiep/:type', lazyloadRouteHandler('./routes/universities/shiep/index'));
3098
+ // 上海电力大学 migrated to v2
3099
+ // router.get('/shiep/:type/:id?', lazyloadRouteHandler('./routes/universities/shiep/index'));
3100
3100
 
3101
3101
  // 福建新闻
3102
3102
  router.get('/fjnews/:city/:limit', lazyloadRouteHandler('./routes/fjnews/fznews'));
@@ -1,14 +1,52 @@
1
+ const cheerio = require('cheerio');
2
+ const got = require('@/utils/got');
3
+ const rssParser = require('@/utils/rss-parser');
1
4
  const { asyncPoolAll, parseArticle } = require('./utils');
2
- const parser = require('@/utils/rss-parser');
5
+
6
+ const parseAuthorNewsList = async (slug) => {
7
+ const baseURL = `https://www.bloomberg.com/authors/${slug}`;
8
+ const apiUrl = `https://www.bloomberg.com/lineup/api/lazy_load_author_stories?slug=${slug}&authorType=default&page=1`;
9
+ const resp = await got(apiUrl);
10
+ // Likely rate limited
11
+ if (!resp.data.html) {
12
+ return [];
13
+ }
14
+ const $ = cheerio.load(resp.data.html);
15
+ const articles = $('article.story-list-story');
16
+ return articles
17
+ .map((index, item) => {
18
+ item = $(item);
19
+ const headline = item.find('a.story-list-story__info__headline-link');
20
+ return {
21
+ title: headline.text(),
22
+ pubDate: item.attr('data-updated-at'),
23
+ guid: `bloomberg:${item.attr('data-id')}`,
24
+ link: new URL(headline.attr('href'), baseURL).href,
25
+ };
26
+ })
27
+ .get();
28
+ };
3
29
 
4
30
  module.exports = async (ctx) => {
5
- const { id, slug } = ctx.params;
6
- const feed = await parser.parseURL(`https://www.bloomberg.com/authors/${id}/${slug}.rss`);
7
- const item = await asyncPoolAll(1, feed.items, (item) => parseArticle(item, ctx));
31
+ const { id, slug, source } = ctx.params;
32
+ const link = `https://www.bloomberg.com/authors/${id}/${slug}`;
33
+
34
+ let list = [];
35
+ if (!source || source === 'api') {
36
+ list = await parseAuthorNewsList(`${id}/${slug}`);
37
+ }
38
+ // Fallback to rss if api failed or requested by param
39
+ if (source === 'rss' || list.length === 0) {
40
+ list = (await rssParser.parseURL(`${link}.rss`)).items;
41
+ }
42
+
43
+ const item = await asyncPoolAll(1, list, (item) => parseArticle(item, ctx));
44
+ const authorName = item.find((i) => i.author)?.author ?? 'Unknown';
45
+
8
46
  ctx.state.data = {
9
- title: `Bloomberg - ${feed.title.split(' - ', 2)[0]}`,
10
- link: feed.link,
11
- language: feed.language,
47
+ title: `Bloomberg - ${authorName}`,
48
+ link,
49
+ language: 'en-us',
12
50
  item,
13
51
  };
14
52
  };
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- '/authors/:id/:slug': ['josh'],
2
+ '/authors/:id/:slug/:source?': ['josh'],
3
3
  '/:site?': ['bigfei'],
4
4
  '/': ['bigfei'],
5
5
  };
@@ -1,5 +1,5 @@
1
1
  module.exports = function (router) {
2
- router.get('/authors/:id/:slug', require('./authors'));
2
+ router.get('/authors/:id/:slug/:source?', require('./authors'));
3
3
  router.get('/:site', require('./index'));
4
4
  router.get('/', require('./index'));
5
5
  };
@@ -6,8 +6,8 @@ const { parseDate } = require('@/utils/parse-date');
6
6
  const dynamicTpye = { 0: '基本动态', 8: '酷图', 9: '评论', 10: '提问', 11: '回答', 12: '图文', 15: '二手', 17: '观点', 20: '交易动态' };
7
7
 
8
8
  const getRandomDEVICE_ID = () => {
9
- let id = [8, 4, 4, 4, 12];
10
- id = id.map((i) => Math.random().toString(36).substr(2, i));
9
+ let id = [10, 6, 6, 6, 14];
10
+ id = id.map((i) => Math.random().toString(36).substring(2, i));
11
11
  return id.join('-');
12
12
  };
13
13
 
@@ -68,6 +68,7 @@ const parseDynamic = async (item, ctx) => {
68
68
  switch (type) {
69
69
  case 0:
70
70
  case 5:
71
+ case 7: // external share
71
72
  case 8:
72
73
  case 9:
73
74
  case 10:
@@ -0,0 +1,86 @@
1
+ const got = require('@/utils/got');
2
+
3
+ const ALLOW_LANGUAGE = {
4
+ en: 'en_GB',
5
+ cn: 'zh_CN',
6
+ tw: 'zh_TW',
7
+ };
8
+
9
+ const TITLE = {
10
+ en: 'The Economist Global Business Review',
11
+ cn: '经济学人 · 商论',
12
+ tw: '經濟學人 · 商論',
13
+ };
14
+
15
+ const DESCRIPTION = {
16
+ en: 'The Economist Global Business Review is a new bilingual digital app from the editors of The Economist Group.',
17
+ cn: '《经济学人·商论》是《经济学人》2015年5月推出的旗下中英双语APP,萃取《经济学人》在商业、金融、科技等领域的精华文章,为中国读者呈现全球视角的深度分析,并鼓励中国的读者批判性地思考中国和全球重大议题。',
18
+ tw: '《經濟學人·商論》是經濟學人集團官方中英雙語電子APP,萃取《經濟學人》在商業、金融、科技等領域的精華文章,為中國讀者呈現全球視角的深度分析,並鼓勵中國的讀者批判性地思考中國和全球的重大議題。',
19
+ };
20
+
21
+ const parseContent = function (item, article_id, language) {
22
+ if (item.type === 'paragraph') {
23
+ return parseParagraph(item.data, language);
24
+ } else if (item.type === 'image') {
25
+ return parseImage(item.data, article_id, language);
26
+ } else if (item.type === 'subtitle') {
27
+ return parseParagraph(item.data, language, 'h3');
28
+ }
29
+ };
30
+
31
+ const parseTitle = function (data, language) {
32
+ const content = Object.assign({}, ...data.map((x) => ({ [x.lang]: x.text })));
33
+ return language.map((item) => content[ALLOW_LANGUAGE[item]]).join('');
34
+ };
35
+
36
+ const parseParagraph = function (data, language, type = 'p') {
37
+ const content = Object.assign({}, ...data.map((x) => ({ [x.lang]: x.text })));
38
+ return `<div>${language.map((item) => `<${type}>${content[ALLOW_LANGUAGE[item]]}</${type}>`).join('')}</div>`;
39
+ };
40
+
41
+ const parseImage = function (data, article_id, language) {
42
+ const content = Object.assign({}, ...data.map((x) => ({ [x.lang]: x.image_path })));
43
+ return `<div><img src="https://businessreviewglobal-cdn.com/article_images/${article_id}/${encodeURIComponent(content[ALLOW_LANGUAGE[language[0]]])}"/></div>`;
44
+ };
45
+
46
+ const getArticleDetail = (article_id, language, ctx) => {
47
+ const link = `https://api.hummingbird.businessreview.global/api/article/index?id=${article_id}`;
48
+ return ctx.cache.tryGet(`${link}:${language.join('-')}`, async () => {
49
+ const response = await got({
50
+ method: 'get',
51
+ url: link,
52
+ });
53
+ const data = response.data.body;
54
+ let content = '';
55
+ content += parseParagraph(data.rubric, language);
56
+ content += data.content.map((item) => parseContent(item, article_id, language)).join('');
57
+ return content;
58
+ });
59
+ };
60
+
61
+ module.exports = async (ctx) => {
62
+ const language = (ctx.params.language && ctx.params.language.split('-').filter((item, index, arr) => ALLOW_LANGUAGE[item] && arr.indexOf(item, 0) === index)) || ['cn', 'en'];
63
+ const main_language = language[0];
64
+
65
+ const response = await got({
66
+ method: 'get',
67
+ url: 'https://api.hummingbird.businessreview.global/api/toc/get_articles',
68
+ });
69
+
70
+ const items = await Promise.all(
71
+ response.data.articles.new.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10).map(async (item) => ({
72
+ title: parseTitle(item.body.title, [main_language]),
73
+ description: await getArticleDetail(item.article_id, language, ctx),
74
+ category: parseTitle(item.body.fly_title, [main_language]),
75
+ link: `https://www.businessreview.global/latest/${item.article_id}`,
76
+ pubDate: item.publication_date,
77
+ }))
78
+ );
79
+
80
+ ctx.state.data = {
81
+ title: TITLE[main_language],
82
+ link: 'https://www.businessreview.global',
83
+ description: DESCRIPTION[main_language],
84
+ item: items,
85
+ };
86
+ };
@@ -2,5 +2,6 @@ module.exports = {
2
2
  '/download': ['nczitzk'],
3
3
  '/espresso': ['TonyRL'],
4
4
  '/gre-vocabulary': ['xyqfer'],
5
+ '/global-business-review/:language?': ['prnake'],
5
6
  '/:endpoint': ['ImSingee'],
6
7
  };
@@ -24,4 +24,15 @@ module.exports = {
24
24
  },
25
25
  ],
26
26
  },
27
+ 'businessreview.global': {
28
+ _name: 'The Economist',
29
+ '.': [
30
+ {
31
+ title: '商论',
32
+ docs: 'https://docs.rsshub.app/traditional-media.html#the-economist',
33
+ source: ['/'],
34
+ target: '/economist/global-business-review',
35
+ },
36
+ ],
37
+ },
27
38
  };
@@ -2,5 +2,6 @@ module.exports = (router) => {
2
2
  router.get('/download', require('./download'));
3
3
  router.get('/espresso', require('./espresso'));
4
4
  router.get('/gre-vocabulary', require('./gre-vocabulary'));
5
+ router.get('/global-business-review/:language?', require('./global-business-review'));
5
6
  router.get('/:endpoint', require('./full'));
6
7
  };
@@ -0,0 +1,37 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const timezone = require('@/utils/timezone');
5
+
6
+ const baseUrl = 'https://www.guandian.cn';
7
+
8
+ module.exports = async (ctx) => {
9
+ const cat = ctx.params.category;
10
+ const reqUrl = `${baseUrl}/${cat}/`;
11
+ const response = await got(reqUrl);
12
+ const $ = cheerio.load(response.data);
13
+
14
+ const items = $('.con_l li')
15
+ .toArray()
16
+ .map((item) => {
17
+ item = $(item);
18
+ const a = item.find('.con_l_con_r a');
19
+ const link = a.attr('href');
20
+ const title = a.find('h3').text();
21
+ const desc = item.find('.con_l_con_r p').text();
22
+
23
+ const dateStr = item.find('#keyword span').text();
24
+ return {
25
+ title,
26
+ link,
27
+ description: desc,
28
+ pubDate: timezone(parseDate(dateStr), 8),
29
+ };
30
+ });
31
+
32
+ ctx.state.data = {
33
+ title: $('head title').text(),
34
+ link: reqUrl,
35
+ item: items,
36
+ };
37
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:category': ['drgnchan'],
3
+ };
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ 'guandian.cn': {
3
+ _name: '观点网',
4
+ www: {
5
+ title: '资讯',
6
+ docs: 'https://docs.rsshub.app/new-media.html#guan-dian-wang-zi-xun',
7
+ source: ['/:category'],
8
+ target: '/guandian/:category',
9
+ },
10
+ },
11
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:category', require('./index'));
3
+ };
@@ -0,0 +1,91 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const dayjs = require('dayjs');
4
+ const path = require('path');
5
+ const { parseDate } = require('@/utils/parse-date');
6
+ const { art } = require('@/utils/render');
7
+
8
+ module.exports = async (ctx) => {
9
+ const type = ctx.params.type;
10
+
11
+ const config = {
12
+ dqxy: { title: '电气工程学院', id: '2462' },
13
+ dxxy: { title: '电子与信息工程学院', id: 'tzgg' },
14
+ energy: { title: '能源与机械工程学院', id: '892' },
15
+ fao: { title: '国际交流与合作处(港澳台办公室)', id: 'tzgg' },
16
+ gjjlxy: { title: '国际交流学院', id: 'tzgg' }, // NAME_NOT_RESOLVED
17
+ hhxy: { title: '环境与化学工程学院', id: '1231' },
18
+ jgxy: { title: '经济与管理学院', id: '3633' },
19
+ jjxy: { title: '继续教育学院', id: '2582' },
20
+ jsjxy: { title: '计算机科学与技术学院', id: '973' },
21
+ jwc: { title: '教务处', id: '227' },
22
+ kyc: { title: '科研处', id: '834' },
23
+ news: { title: '新闻网', id: 'notice' },
24
+ rsc: { title: '党委教师工作部、人事处', id: '1695' },
25
+ skb: { title: '马克思主义学院', id: '1736' },
26
+ slxy: { title: '数理学院', id: '2063' },
27
+ tyb: { title: '体育学院', id: '2891' },
28
+ wgyxy: { title: '外国语学院', id: 'tzgg' },
29
+ xxgk: { title: '信息公开网', id: 'zxgkxx' },
30
+ yjsc: { title: '研究生院/研工部', id: '1161' },
31
+ yjzx: { title: '人文艺术学院', id: '3089' }, // NAME_NOT_RESOLVED
32
+ zdhxy: { title: '自动化工程学院', id: '2002' },
33
+ zs: { title: '本科招生网', id: 'zxxx' },
34
+ };
35
+
36
+ if (!Object.keys(config).includes(type)) {
37
+ throw Error('Invalid type');
38
+ }
39
+
40
+ const host = `https://${type}.shiep.edu.cn`;
41
+ const id = ctx.params.id || config[type].id;
42
+ const pubDateClass = type === 'dxxy' ? 'div[class="article-publishdate"]' : 'span[class="Article_PublishDate"]'; // 适配电子与信息工程学院网站改版
43
+
44
+ const response = await got(`${host}/${id}/list.htm`);
45
+
46
+ const $ = cheerio.load(response.data);
47
+
48
+ const items = $('.list_item')
49
+ .toArray()
50
+ .filter((item) => {
51
+ const date = dayjs($(item).find(pubDateClass).text().trim());
52
+ return date.isValid();
53
+ })
54
+ .map((item) => {
55
+ item = $(item);
56
+ return {
57
+ title: item.find('a').attr('title') || item.find('a').text(),
58
+ link: new URL(item.find('a').attr('href'), host).href,
59
+ pubDate: parseDate(item.find(pubDateClass).text().trim(), 'YYYY-MM-DD'),
60
+ };
61
+ });
62
+
63
+ await Promise.all(
64
+ items.map((item) =>
65
+ ctx.cache.tryGet(item.link, async () => {
66
+ try {
67
+ const response = await got(item.link);
68
+ const $ = cheerio.load(response.data);
69
+
70
+ if ($('.wp_articlecontent').length > 0) {
71
+ item.description = art(path.resolve(__dirname, 'templates/description.art'), {
72
+ description: $('.wp_articlecontent').html(),
73
+ });
74
+ } else {
75
+ item.description = '请进行统一身份认证后查看内容';
76
+ }
77
+ } catch (e) {
78
+ item.description = '请在校内或通过校园VPN查看内容';
79
+ }
80
+ return item;
81
+ })
82
+ )
83
+ );
84
+
85
+ ctx.state.data = {
86
+ title: '上海电力大学-' + config[type].title,
87
+ link: `${host}/${id}/list.htm`,
88
+ description: '上海电力大学-' + config[type].title,
89
+ item: items,
90
+ };
91
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:type/:id?': ['gumibea', 'TeamSUEP'],
3
+ };
@@ -0,0 +1,181 @@
1
+ module.exports = {
2
+ 'shiep.edu.cn': {
3
+ _name: '上海电力大学',
4
+ dqxy: [
5
+ {
6
+ title: '电气工程学院',
7
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
8
+ source: ['/:id/list.htm'],
9
+ target: '/shiep/dqxy/:id',
10
+ },
11
+ ],
12
+ dxxy: [
13
+ {
14
+ title: '电子信息工程学院',
15
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
16
+ source: ['/:id/list.htm'],
17
+ target: '/shiep/dxxy/:id',
18
+ },
19
+ ],
20
+ energy: [
21
+ {
22
+ title: '能源与机械工程学院',
23
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
24
+ source: ['/:id/list.htm'],
25
+ target: '/shiep/energy/:id',
26
+ },
27
+ ],
28
+ fao: [
29
+ {
30
+ title: '国际交流与合作处(港澳台办公室)',
31
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
32
+ source: ['/:id/list.htm'],
33
+ target: '/shiep/fao/:id',
34
+ },
35
+ ],
36
+ gjjlxy: [
37
+ {
38
+ title: '国际交流学院',
39
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
40
+ source: ['/:id/list.htm'],
41
+ target: '/shiep/gjjlxy/:id',
42
+ },
43
+ ],
44
+ hhxy: [
45
+ {
46
+ title: '环境与化学工程学院',
47
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
48
+ source: ['/:id/list.htm'],
49
+ target: '/shiep/hhxy/:id',
50
+ },
51
+ ],
52
+ jgxy: [
53
+ {
54
+ title: '经济与管理学院',
55
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
56
+ source: ['/:id/list.htm'],
57
+ target: '/shiep/jgxy/:id',
58
+ },
59
+ ],
60
+ jjxy: [
61
+ {
62
+ title: '继续教育学院',
63
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
64
+ source: ['/:id/list.htm'],
65
+ target: '/shiep/jjxy/:id',
66
+ },
67
+ ],
68
+ jsjxy: [
69
+ {
70
+ title: '计算机科学与技术学院',
71
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
72
+ source: ['/:id/list.htm'],
73
+ target: '/shiep/jsjxy/:id',
74
+ },
75
+ ],
76
+ jwc: [
77
+ {
78
+ title: '教务处',
79
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
80
+ source: ['/:id/list.htm'],
81
+ target: '/shiep/jwc/:id',
82
+ },
83
+ ],
84
+ kyc: [
85
+ {
86
+ title: '科研处',
87
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
88
+ source: ['/:id/list.htm'],
89
+ target: '/shiep/kyc/:id',
90
+ },
91
+ ],
92
+ news: [
93
+ {
94
+ title: '新闻网',
95
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
96
+ source: ['/:id/list.htm'],
97
+ target: '/shiep/news/:id',
98
+ },
99
+ ],
100
+ rsc: [
101
+ {
102
+ title: '党委教师工作部、人事处',
103
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
104
+ source: ['/:id/list.htm'],
105
+ target: '/shiep/rsc/:id',
106
+ },
107
+ ],
108
+ skb: [
109
+ {
110
+ title: '马克思主义学院',
111
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
112
+ source: ['/:id/list.htm'],
113
+ target: '/shiep/skb/:id',
114
+ },
115
+ ],
116
+ slxy: [
117
+ {
118
+ title: '数理学院',
119
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
120
+ source: ['/:id/list.htm'],
121
+ target: '/shiep/slxy/:id',
122
+ },
123
+ ],
124
+ tyb: [
125
+ {
126
+ title: '体育学院',
127
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
128
+ source: ['/:id/list.htm'],
129
+ target: '/shiep/tyb/:id',
130
+ },
131
+ ],
132
+ wgyxy: [
133
+ {
134
+ title: '外国语学院',
135
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
136
+ source: ['/:id/list.htm'],
137
+ target: '/shiep/wgyxy/:id',
138
+ },
139
+ ],
140
+ xxgk: [
141
+ {
142
+ title: '信息公开网',
143
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
144
+ source: ['/:id/list.htm'],
145
+ target: '/shiep/xxgk/:id',
146
+ },
147
+ ],
148
+ yjsc: [
149
+ {
150
+ title: '研究生院/研工部',
151
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
152
+ source: ['/:id/list.htm'],
153
+ target: '/shiep/yjsc/:id',
154
+ },
155
+ ],
156
+ yjzx: [
157
+ {
158
+ title: '人文艺术学院',
159
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
160
+ source: ['/:id/list.htm'],
161
+ target: '/shiep/yjzx/:id',
162
+ },
163
+ ],
164
+ zdhxy: [
165
+ {
166
+ title: '自动化工程学院',
167
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
168
+ source: ['/:id/list.htm'],
169
+ target: '/shiep/zdhxy/:id',
170
+ },
171
+ ],
172
+ zs: [
173
+ {
174
+ title: '本科招生网',
175
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
176
+ source: ['/:id/list.htm'],
177
+ target: '/shiep/zs/:id',
178
+ },
179
+ ],
180
+ },
181
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:type/:id?', require('./index'));
3
+ };
@@ -0,0 +1 @@
1
+ {{@ description }}
@@ -0,0 +1,34 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate } = require('@/utils/parse-date');
3
+ const { baseUrl, fetchUserDate } = require('./utils');
4
+
5
+ module.exports = async (ctx) => {
6
+ const { author } = ctx.params;
7
+
8
+ const userData = await fetchUserDate(author);
9
+ const { author_id: authorId } = userData;
10
+
11
+ const {
12
+ data: { result: letters },
13
+ } = await got(`${baseUrl}/api/app/users/${authorId}/letters`, {
14
+ searchParams: {
15
+ page: 1,
16
+ limit: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
17
+ },
18
+ });
19
+
20
+ const items = letters.map((item) => ({
21
+ title: item.title,
22
+ description: item.shortcut,
23
+ pubDate: parseDate(item.send_time, 'X'),
24
+ link: `${baseUrl}/letter/${item.id}`,
25
+ }));
26
+
27
+ ctx.state.data = {
28
+ title: userData.author_name,
29
+ link: `${baseUrl}/${author}`,
30
+ description: userData.author_signature,
31
+ image: userData.author_avatar_url,
32
+ item: items,
33
+ };
34
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '/letters/:author': ['TonyRL'],
3
+ '/posts/:author': ['TonyRL'],
4
+ };
@@ -0,0 +1,69 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate } = require('@/utils/parse-date');
3
+ const { baseUrl, fetchUserDate } = require('./utils');
4
+ const { art } = require('@/utils/render');
5
+ const path = require('path');
6
+ const dayjs = require('dayjs');
7
+
8
+ module.exports = async (ctx) => {
9
+ art.defaults.imports = {
10
+ dayjs,
11
+ ...art.defaults.imports,
12
+ };
13
+
14
+ const { author } = ctx.params;
15
+
16
+ const userData = await fetchUserDate(author);
17
+ const { author_id: authorId } = userData;
18
+
19
+ const {
20
+ data: { result: posts },
21
+ } = await got(`${baseUrl}/api/app/share/garden/users/${authorId}/posts`, {
22
+ searchParams: {
23
+ page: 1,
24
+ limit: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
25
+ },
26
+ });
27
+
28
+ const list = posts.map((item) => ({
29
+ title: item.title,
30
+ pubDate: parseDate(item.create_time, 'X'),
31
+ link: `${baseUrl}/b${item.share_md5}`,
32
+ guid: `${baseUrl}/b${item.share_md5}:${item.link_amount}:${item.note_amount}`,
33
+ postId: item.id,
34
+ shareMD5: item.share_md5,
35
+ }));
36
+
37
+ const items = await Promise.all(
38
+ list.map((item) =>
39
+ ctx.cache.tryGet(item.link, async () => {
40
+ const { data: postMeta } = await got(`${baseUrl}/api/app/share/posts/${item.shareMD5}`);
41
+
42
+ const {
43
+ data: { result: posts },
44
+ } = await got(`${baseUrl}/api/app/share/posts/${item.postId}/notes`, {
45
+ searchParams: {
46
+ page: 1,
47
+ limit: 100,
48
+ },
49
+ });
50
+
51
+ item.description = art(path.join(__dirname, 'templates/post.art'), {
52
+ postMeta,
53
+ postDate: dayjs(postMeta.create_time, 'X').format('YYYY-MM-DD HH:mm:ss'),
54
+ posts,
55
+ });
56
+
57
+ return item;
58
+ })
59
+ )
60
+ );
61
+
62
+ ctx.state.data = {
63
+ title: userData.author_name,
64
+ link: `${baseUrl}/${author}`,
65
+ description: userData.author_signature,
66
+ image: userData.author_avatar_url,
67
+ item: items,
68
+ };
69
+ };
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ 'zhiy.cc': {
3
+ _name: '知园',
4
+ '.': [
5
+ {
6
+ title: 'Newsletter',
7
+ docs: 'https://docs.rsshub.app/new-media.html#zhi-yuan',
8
+ source: ['/:author'],
9
+ target: '/zhiy/letters/:author',
10
+ },
11
+ {
12
+ title: '笔记',
13
+ docs: 'https://docs.rsshub.app/new-media.html#zhi-yuan',
14
+ source: ['/:author'],
15
+ target: '/zhiy/posts/:author',
16
+ },
17
+ ],
18
+ },
19
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = (router) => {
2
+ router.get('/letters/:author', require('./letter'));
3
+ router.get('/posts/:author', require('./post'));
4
+ };
@@ -0,0 +1,12 @@
1
+ {{ postMeta.visit_amount }}阅读 {{ postMeta.note_amount }}条笔记 创建于{{ postDate }}
2
+ <br>
3
+ {{ each posts post }}
4
+ {{ each post.struct.items item }}
5
+ {{ if item.type === 'text' }}<span>{{@ item.content.replace(/\n/g, '<br>') }}</span>{{ /if }}
6
+ {{ if item.type === 'url' }}<a href="{{ item.url }}">{{ item.content }}</a>{{ /if }}
7
+ {{ if item.type === 'link' }}<span>{{@ item.content.replace(/\n/g, '<br>') }}</span>{{ /if }}
8
+ {{ /each }}
9
+ <br>
10
+ {{ dayjs(post.publish_time_timestamp, 'X').format('YYYY-MM-DD HH:mm:ss') }}
11
+ <hr>
12
+ {{ /each }}
@@ -0,0 +1,13 @@
1
+ const got = require('@/utils/got');
2
+
3
+ const baseUrl = 'https://zhiy.cc';
4
+
5
+ const fetchUserDate = async (author) => {
6
+ const { data: userData } = await got(`${baseUrl}/api/app/share/garden/users/${author}`);
7
+ return userData;
8
+ };
9
+
10
+ module.exports = {
11
+ baseUrl,
12
+ fetchUserDate,
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsshub",
3
- "version": "1.0.0-master.cf674e2",
3
+ "version": "1.0.0-master.cf6dff4",
4
4
  "description": "Make RSS Great Again!",
5
5
  "main": "lib/pkg.js",
6
6
  "files": [
@@ -56,7 +56,7 @@
56
56
  "@vuepress/plugin-pwa": "1.9.8",
57
57
  "@vuepress/shared-utils": "1.9.8",
58
58
  "cross-env": "7.0.3",
59
- "eslint": "8.31.0",
59
+ "eslint": "8.32.0",
60
60
  "eslint-config-prettier": "8.6.0",
61
61
  "eslint-plugin-prettier": "4.2.1",
62
62
  "eslint-plugin-yml": "1.4.0",
@@ -91,7 +91,7 @@
91
91
  "dependencies": {
92
92
  "@koa/router": "12.0.0",
93
93
  "@postlight/parser": "2.2.3",
94
- "@sentry/node": "7.30.0",
94
+ "@sentry/node": "7.31.1",
95
95
  "aes-js": "3.1.2",
96
96
  "art-template": "4.13.2",
97
97
  "bbcodejs": "0.0.4",
@@ -146,7 +146,7 @@
146
146
  "tiny-async-pool": "2.1.0",
147
147
  "torrent-search-api": "2.1.4",
148
148
  "tough-cookie": "4.1.2",
149
- "twitter-api-v2": "1.13.0",
149
+ "twitter-api-v2": "1.14.0",
150
150
  "winston": "3.8.2",
151
151
  "xml2js": "0.4.23"
152
152
  },
@@ -1,95 +0,0 @@
1
- const got = require('@/utils/got');
2
- const cheerio = require('cheerio');
3
-
4
- module.exports = async (ctx) => {
5
- const type = ctx.params.type;
6
-
7
- const config = {
8
- news: {
9
- title: '新闻网',
10
- url: 'notice',
11
- },
12
- energy: {
13
- title: '能机学院',
14
- url: '894',
15
- },
16
- hhxy: {
17
- title: '环化学院',
18
- url: '1231',
19
- },
20
- dqxy: {
21
- title: '电气学院',
22
- url: '2462',
23
- },
24
- zdhxy: {
25
- title: '自动化学院',
26
- url: '2002',
27
- },
28
- jsjxy: {
29
- title: '计算机学院',
30
- url: '973',
31
- },
32
- dxxy: {
33
- title: '电信学院',
34
- url: '3404',
35
- },
36
- jgxy: {
37
- title: '经管学院',
38
- url: '3633',
39
- },
40
- slxy: {
41
- title: '数理学院',
42
- url: '2063',
43
- },
44
- wgyxy: {
45
- title: '外国语学院',
46
- url: 'tzgg',
47
- },
48
- gjjlxy: {
49
- title: '国交学院',
50
- url: 'tzgg',
51
- },
52
- jjxy: {
53
- title: '继续教育学院',
54
- url: '2582',
55
- },
56
- skb: {
57
- title: '马院',
58
- url: '1736',
59
- },
60
- tyb: {
61
- title: '体育部',
62
- url: '2891',
63
- },
64
- yjzx: {
65
- title: '艺教中心',
66
- url: '3089',
67
- },
68
- };
69
-
70
- const link = config[type].url;
71
-
72
- const { data } = await got({
73
- method: 'get',
74
- url: `https://${type}.shiep.edu.cn/${link}/list.htm`,
75
- });
76
-
77
- const $ = cheerio.load(data);
78
- const list = $('div[class="fields pr_fields"]');
79
-
80
- ctx.state.data = {
81
- title: '上海电力大学-' + config[type].title,
82
- link: `https://${type}.shiep.edu.cn/${link}/list.htm`,
83
- item:
84
- list &&
85
- list
86
- .map((index, item) => {
87
- item = $(item);
88
- return {
89
- title: item.find('a').text(),
90
- link: item.find('a').attr('href'),
91
- };
92
- })
93
- .get(),
94
- };
95
- };