rsshub 1.0.0-master.d2b1df9 → 1.0.0-master.d2bf7b3

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.
Files changed (122) hide show
  1. package/lib/config.js +3 -0
  2. package/lib/middleware/cache/index.js +3 -0
  3. package/lib/router.js +5 -5
  4. package/lib/v2/bangumi/maintainer.js +1 -0
  5. package/lib/v2/bangumi/online.js +26 -0
  6. package/lib/v2/bangumi/radar.js +13 -2
  7. package/lib/v2/bangumi/router.js +1 -0
  8. package/lib/v2/bangumi/templates/image.art +1 -0
  9. package/lib/v2/bilibili/collection.js +34 -0
  10. package/lib/v2/bilibili/maintainer.js +1 -0
  11. package/lib/v2/bilibili/radar.js +9 -0
  12. package/lib/v2/bilibili/router.js +1 -0
  13. package/lib/v2/china/maintainer.js +4 -0
  14. package/lib/v2/china/news/highlights/news.js +40 -0
  15. package/lib/v2/china/news/military/news.js +31 -0
  16. package/lib/v2/china/radar.js +21 -0
  17. package/lib/v2/china/router.js +4 -0
  18. package/lib/v2/csdn/blog.js +39 -0
  19. package/lib/v2/csdn/maintainer.js +3 -0
  20. package/lib/v2/csdn/radar.js +13 -0
  21. package/lib/v2/csdn/router.js +3 -0
  22. package/lib/v2/douyu/post.js +9 -2
  23. package/lib/v2/github/comments.js +3 -4
  24. package/lib/v2/hupu/bbs.js +23 -23
  25. package/lib/v2/huxiu/maintainer.js +1 -0
  26. package/lib/v2/huxiu/moment.js +40 -0
  27. package/lib/v2/huxiu/radar.js +6 -0
  28. package/lib/v2/huxiu/router.js +1 -0
  29. package/lib/v2/huxiu/templates/moment.art +16 -0
  30. package/lib/v2/iwara/maintainer.js +1 -0
  31. package/lib/v2/iwara/radar.js +6 -0
  32. package/lib/v2/iwara/router.js +1 -0
  33. package/lib/v2/iwara/subscriptions.js +49 -0
  34. package/lib/v2/iwara/templates/subscriptions.art +1 -0
  35. package/lib/v2/leetcode/dailyquestion-solution-cn.js +183 -0
  36. package/lib/v2/leetcode/dailyquestion-solution-en.js +213 -0
  37. package/lib/v2/leetcode/maintainer.js +1 -0
  38. package/lib/v2/leetcode/radar.js +12 -0
  39. package/lib/v2/leetcode/router.js +2 -0
  40. package/lib/v2/lovelive-anime/maintainer.js +3 -0
  41. package/lib/v2/lovelive-anime/news.js +56 -0
  42. package/lib/v2/lovelive-anime/radar.js +13 -0
  43. package/lib/v2/lovelive-anime/router.js +3 -0
  44. package/lib/v2/lovelive-anime/templates/description.art +1 -0
  45. package/lib/v2/macfilos/blog.js +61 -0
  46. package/lib/v2/macfilos/maintainer.js +3 -0
  47. package/lib/v2/macfilos/radar.js +13 -0
  48. package/lib/v2/macfilos/router.js +3 -0
  49. package/lib/v2/meteor/boards.js +11 -0
  50. package/lib/v2/meteor/index.js +45 -0
  51. package/lib/v2/meteor/maintainer.js +4 -0
  52. package/lib/v2/meteor/radar.js +19 -0
  53. package/lib/v2/meteor/router.js +4 -0
  54. package/lib/v2/meteor/templates/desc.art +7 -0
  55. package/lib/v2/meteor/utils.js +90 -0
  56. package/lib/v2/nikkei-cn/index.js +4 -1
  57. package/lib/v2/nua/gra.js +56 -0
  58. package/lib/v2/nua/maintainer.js +3 -0
  59. package/lib/v2/nua/radar.js +13 -0
  60. package/lib/v2/nua/router.js +3 -0
  61. package/lib/v2/oschina/maintainer.js +6 -0
  62. package/lib/{routes → v2}/oschina/news.js +35 -39
  63. package/lib/v2/oschina/radar.js +33 -0
  64. package/lib/v2/oschina/router.js +6 -0
  65. package/lib/v2/oschina/topic.js +53 -0
  66. package/lib/v2/oschina/user.js +50 -0
  67. package/lib/v2/plurk/anonymous.js +23 -0
  68. package/lib/v2/plurk/hotlinks.js +20 -0
  69. package/lib/v2/plurk/maintainer.js +9 -0
  70. package/lib/v2/plurk/news.js +23 -0
  71. package/lib/v2/plurk/radar.js +56 -0
  72. package/lib/v2/plurk/router.js +9 -0
  73. package/lib/v2/plurk/search.js +27 -0
  74. package/lib/v2/plurk/top.js +29 -0
  75. package/lib/v2/plurk/topic.js +33 -0
  76. package/lib/v2/plurk/user.js +31 -0
  77. package/lib/v2/plurk/utils.js +56 -0
  78. package/lib/v2/segmentfault/blogs.js +38 -0
  79. package/lib/v2/segmentfault/maintainer.js +1 -0
  80. package/lib/v2/segmentfault/radar.js +8 -2
  81. package/lib/v2/segmentfault/router.js +1 -0
  82. package/lib/v2/sensortower/blog.js +69 -0
  83. package/lib/v2/sensortower/maintainer.js +3 -0
  84. package/lib/v2/sensortower/radar.js +13 -0
  85. package/lib/v2/sensortower/router.js +3 -0
  86. package/lib/v2/sensortower/templates/description.art +9 -0
  87. package/lib/v2/taptap/templates/imagePost.art +3 -0
  88. package/lib/v2/taptap/templates/videoPost.art +2 -1
  89. package/lib/v2/taptap/topic.js +33 -27
  90. package/lib/v2/taptap/utils.js +13 -8
  91. package/lib/v2/test/index.js +15 -0
  92. package/lib/v2/trending/allTrending.js +46 -19
  93. package/lib/v2/trending/templates/content.art +1 -0
  94. package/lib/v2/twitter/maintainer.js +1 -1
  95. package/lib/v2/twitter/router.js +1 -1
  96. package/lib/v2/twitter/web-api/twitter-api.js +1 -0
  97. package/lib/v2/warthunder/maintainer.js +3 -0
  98. package/lib/v2/warthunder/news.js +49 -0
  99. package/lib/v2/warthunder/radar.js +13 -0
  100. package/lib/v2/warthunder/router.js +3 -0
  101. package/lib/v2/warthunder/templates/description.art +1 -0
  102. package/lib/v2/xyzrank/index.js +111 -0
  103. package/lib/v2/xyzrank/maintainer.js +6 -0
  104. package/lib/v2/xyzrank/radar.js +31 -0
  105. package/lib/v2/xyzrank/router.js +3 -0
  106. package/lib/v2/xyzrank/templates/description.art +12 -0
  107. package/lib/v2/zaobao/util.js +6 -6
  108. package/lib/v2/zuvio/boards.js +14 -0
  109. package/lib/v2/zuvio/radar.js +13 -0
  110. package/lib/v2/zuvio/router.js +4 -0
  111. package/lib/v2/zuvio/student5.js +58 -0
  112. package/lib/v2/zuvio/templates/img.art +2 -0
  113. package/lib/v2/zuvio/templates/link.art +7 -0
  114. package/lib/v2/zuvio/templates/ref_article.art +8 -0
  115. package/lib/v2/zuvio/templates/rss.art +1 -0
  116. package/lib/v2/zuvio/templates/youtube.art +2 -0
  117. package/lib/v2/zuvio/utils.js +61 -0
  118. package/package.json +14 -15
  119. package/lib/routes/oschina/topic.js +0 -54
  120. package/lib/routes/oschina/u.js +0 -57
  121. package/lib/routes/oschina/user.js +0 -57
  122. package/lib/v2/hupu/templates/description.art +0 -6
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ 'meteor.today': {
3
+ _name: 'Meteor',
4
+ '.': [
5
+ {
6
+ title: '看板',
7
+ docs: 'https://docs.rsshub.app/bbs.html#meteor',
8
+ source: ['/board/:board', '/board/:board/new'],
9
+ target: '/meteor/board/:board',
10
+ },
11
+ {
12
+ title: '看板列表',
13
+ docs: 'https://docs.rsshub.app/bbs.html#meteor',
14
+ source: ['/'],
15
+ target: '/meteor/boards',
16
+ },
17
+ ],
18
+ },
19
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = (router) => {
2
+ router.get('/boards', require('./boards'));
3
+ router.get('/:board?', require('./index'));
4
+ };
@@ -0,0 +1,7 @@
1
+ {{ if youTube }}
2
+ <iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/{{ youTube }}" frameborder="0" allowfullscreen></iframe>
3
+ {{ else if img }}
4
+ <img src="{{ img }}">
5
+ {{ else if video }}
6
+ <video src="{{ video }}" controls></video>
7
+ {{ /if }}
@@ -0,0 +1,90 @@
1
+ const got = require('@/utils/got');
2
+ const { art } = require('@/utils/render');
3
+ const path = require('path');
4
+ const baseUrl = 'https://meteor.today';
5
+
6
+ const getBoards = (tryGet) =>
7
+ tryGet('meteor:boards', async () => {
8
+ const { data: response } = await got.post(`${baseUrl}/board/get_boards`, {
9
+ json: {
10
+ isCollege: 'false',
11
+ },
12
+ });
13
+
14
+ return JSON.parse(decodeURIComponent(response.result)).map((item) => ({
15
+ title: `${item.category ? `${item.category} - ` : ''}${item.name}`,
16
+ description: item.id,
17
+ feedDescription: item.description,
18
+ category: item.articleCategory,
19
+ link: `${baseUrl}/board/${item.alias ? item.alias : item.name}`,
20
+ alias: item.alias,
21
+ imgUrl: item.imageUrl,
22
+ id: item.id,
23
+ }));
24
+ });
25
+
26
+ const renderDesc = (desc) => {
27
+ const youTube = /(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)&?/g;
28
+ const matchYouTube = desc.match(youTube);
29
+ const matchImgur = desc.match(/https:\/\/i.imgur.com\/\w*.(jpg|png|gif|jpeg)/g);
30
+ const matchVideo = desc.match(/(https:\/\/storage\.meteor\.today\/video\/[0-9a-fA-F]{24}\.)(mp4|mov|avi|flv|wmv|mpeg|mkv)/gi);
31
+ const matchSticker = desc.match(/assets\/images\/stickers\/(duck|ep2|ep1)\/\w*.(jpg|png|gif|jpeg)/g);
32
+ const matchEmoji = desc.match(/assets\/images\/emoji\/\w*.(jpg|png|gif|jpeg)/g);
33
+
34
+ if (matchYouTube) {
35
+ desc = desc.replace(
36
+ youTube,
37
+ art(path.join(__dirname, 'templates/desc.art'), {
38
+ youTube: '$1',
39
+ })
40
+ );
41
+ }
42
+ if (matchImgur) {
43
+ for (const img of matchImgur) {
44
+ desc = desc.replace(
45
+ img,
46
+ art(path.join(__dirname, 'templates/desc.art'), {
47
+ img,
48
+ })
49
+ );
50
+ }
51
+ }
52
+ if (matchVideo) {
53
+ for (const video of matchVideo) {
54
+ desc = desc.replace(
55
+ video,
56
+ art(path.join(__dirname, 'templates/desc.art'), {
57
+ video,
58
+ })
59
+ );
60
+ }
61
+ }
62
+ if (matchSticker) {
63
+ for (const sticker of matchSticker) {
64
+ desc = desc.replace(
65
+ sticker,
66
+ art(path.join(__dirname, 'templates/desc.art'), {
67
+ img: sticker,
68
+ })
69
+ );
70
+ }
71
+ }
72
+ if (matchEmoji) {
73
+ for (const emoji of matchEmoji) {
74
+ desc = desc.replace(
75
+ emoji,
76
+ art(path.join(__dirname, 'templates/desc.art'), {
77
+ img: emoji,
78
+ })
79
+ );
80
+ }
81
+ }
82
+
83
+ return desc.replace(/\n/g, '<br>');
84
+ };
85
+
86
+ module.exports = {
87
+ baseUrl,
88
+ getBoards,
89
+ renderDesc,
90
+ };
@@ -14,7 +14,10 @@ const cleanContent = (language, content) => {
14
14
  }
15
15
  };
16
16
 
17
- const getPubDate = (link) => timezone(parseDate(link.match(/(\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2})/)[1], 'YYYY-MM-DD-HH-mm-ss'), +9);
17
+ const getPubDate = (link) => {
18
+ const matches = link.match(/(\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}|\d{8})/);
19
+ return matches ? timezone(parseDate(matches[1], 'YYYY-MM-DD-HH-mm-ss'), +9) : undefined;
20
+ };
18
21
 
19
22
  module.exports = async (ctx) => {
20
23
  const language = ctx.params.language ?? 'cn';
@@ -0,0 +1,56 @@
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
+ const baseUrl = 'https://grad.nua.edu.cn';
6
+
7
+ module.exports = async (ctx) => {
8
+ const type = ctx.params.type;
9
+ const newsUrl = `${baseUrl}/${type}/list.htm`;
10
+
11
+ const response = await got(newsUrl, {
12
+ https: {
13
+ rejectUnauthorized: false,
14
+ },
15
+ });
16
+
17
+ const data = response.data;
18
+ const $ = cheerio.load(data);
19
+ const pagename = $('.col_title').text();
20
+
21
+ const items = $('li.list_item')
22
+ .toArray()
23
+ .map((item) => {
24
+ item = $(item);
25
+ return {
26
+ link: baseUrl + item.find('a').attr('href'),
27
+ title: item.find('a').attr('title'),
28
+ pubDate: timezone(parseDate(item.find('.Article_PublishDate').first().text(), 'YYYY-MM-DD'), +8),
29
+ };
30
+ });
31
+
32
+ const results = await Promise.all(
33
+ items.map((item) =>
34
+ ctx.cache.tryGet(item.link, async () => {
35
+ const result = await got(item.link, {
36
+ https: {
37
+ rejectUnauthorized: false,
38
+ },
39
+ });
40
+ const $ = cheerio.load(result.data);
41
+
42
+ item.author = $('.arti_publisher').text();
43
+ item.description = $('.read').html();
44
+
45
+ return item;
46
+ })
47
+ )
48
+ );
49
+
50
+ ctx.state.data = {
51
+ title: 'NUA-研究生处-' + pagename,
52
+ link: `${baseUrl}/${type}/list.htm`,
53
+ description: '南京艺术学院研究生处' + pagename,
54
+ item: results,
55
+ };
56
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/gra/:type': ['evnydd0sf'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'nua.edu.cn': {
3
+ _name: '南京艺术学院',
4
+ grad: [
5
+ {
6
+ title: '研究生处',
7
+ docs: 'https://docs.rsshub.app/university.html#nan-jing-yi-shu-xue-yuan',
8
+ source: ['/:type/list.htm'],
9
+ target: '/nua/gra/:type',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/gra/:type', require('./gra'));
3
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ '/news/:category?': ['tgly307', 'zengxs'],
3
+ '/topic/:topic': ['loveely7'],
4
+ '/u/:id': ['dxmpalb'],
5
+ '/user/:id': ['dxmpalb'],
6
+ };
@@ -1,10 +1,8 @@
1
- const url = require('url');
2
1
  const got = require('@/utils/got');
3
- const date = require('@/utils/date');
2
+ const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
3
+ const timezone = require('@/utils/timezone');
4
4
  const cheerio = require('cheerio');
5
5
 
6
- const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0';
7
-
8
6
  const configs = {
9
7
  all: {
10
8
  name: '最新资讯',
@@ -34,59 +32,57 @@ const configs = {
34
32
  };
35
33
 
36
34
  module.exports = async (ctx) => {
37
- const category = ctx.params.category || 'all';
35
+ const category = ctx.params.category ?? 'all';
38
36
  const config = configs[category];
39
37
 
40
- const res = await got({
41
- method: 'get',
42
- url: config.ajaxUrl,
38
+ const res = await got(config.ajaxUrl, {
43
39
  headers: {
44
- 'User-Agent': USER_AGENT,
45
40
  Referer: config.link,
46
41
  'X-Requested-With': 'XMLHttpRequest',
47
42
  },
48
43
  });
49
44
  const $ = cheerio.load(res.data);
50
- $('.ad-wrap').remove();
51
- const list = $('.items').find('.news-item');
52
- const count = [];
53
- for (let i = 0; i < Math.min(list.length, 10); i++) {
54
- count.push(i);
55
- }
56
- const resultItem = await Promise.all(
57
- count.map(async (i) => {
58
- const each = $(list[i]);
59
- const originalUrl = each.find('a', 'h3').attr('href');
60
- const item = {
61
- title: each.find('a', 'h3').attr('title'),
62
- description: each.find('p', '.description').text(),
63
- link: url.resolve('https://www.oschina.net', encodeURI(originalUrl)),
64
- pubDate: date(each.find('.extra > .list > .item:nth-of-type(2)').text()),
45
+
46
+ const list = $('.items .news-item')
47
+ .toArray()
48
+ .map((item) => {
49
+ item = $(item);
50
+ const date = item.find('.extra > .list > .item:nth-of-type(2)').text();
51
+ return {
52
+ title: item.find('h3 a').attr('title'),
53
+ description: item.find('.description p').text(),
54
+ link: item.find('h3 a').attr('href'),
55
+ pubDate: timezone(/\//.test(date) ? parseDate(date, ['YYYY/MM/DD HH:mm', 'MM/DD HH:mm']) : parseRelativeDate(date), +8),
65
56
  };
66
- if (/^https?:\/\/www.oschina.net\/news\/.*$/.test(originalUrl)) {
67
- const key = 'oschina' + item.link;
68
- const value = await ctx.cache.get(key);
57
+ });
69
58
 
70
- if (value) {
71
- item.description = value;
72
- } else {
73
- const detail = await got({
74
- method: 'get',
75
- url: item.link,
59
+ const resultItem = await Promise.all(
60
+ list.map((item) =>
61
+ ctx.cache.tryGet(item.link, async () => {
62
+ if (/^https?:\/\/(my|www)\.oschina.net\/.*$/.test(item.link)) {
63
+ const detail = await got(item.link, {
76
64
  headers: {
77
- 'User-Agent': USER_AGENT,
78
65
  Referer: config.link,
79
66
  },
80
67
  });
81
68
  const content = cheerio.load(detail.data);
82
- content('.ad-wrap').remove();
69
+
83
70
  item.description = content('.article-detail').html();
84
71
  item.author = content('.article-box__meta .item').first().text();
85
- ctx.cache.set(key, item.description);
86
72
  }
87
- }
88
- return item;
89
- })
73
+ if (/^https?:\/\/gitee.com\/.*$/.test(item.link)) {
74
+ const detail = await got(item.link, {
75
+ headers: {
76
+ Referer: config.link,
77
+ },
78
+ });
79
+ const content = cheerio.load(detail.data);
80
+
81
+ item.description = content('.file_content').html();
82
+ }
83
+ return item;
84
+ })
85
+ )
90
86
  );
91
87
 
92
88
  ctx.state.data = {
@@ -0,0 +1,33 @@
1
+ module.exports = {
2
+ 'oschina.net': {
3
+ _name: '开源中国',
4
+ '.': [
5
+ {
6
+ title: '资讯',
7
+ docs: 'https://docs.rsshub.app/programming.html#kai-yuan-zhong-guo',
8
+ source: ['/news/:category'],
9
+ target: '/oschina/news/:category',
10
+ },
11
+ {
12
+ title: '问答主题',
13
+ docs: 'https://docs.rsshub.app/programming.html#kai-yuan-zhong-guo',
14
+ source: ['/question/topic/:topic'],
15
+ target: '/oschina/topic/:topic',
16
+ },
17
+ ],
18
+ my: [
19
+ {
20
+ title: '用户博客',
21
+ docs: 'https://docs.rsshub.app/programming.html#kai-yuan-zhong-guo',
22
+ source: ['/:id'],
23
+ target: '/oschina/user/:id',
24
+ },
25
+ {
26
+ title: '数字型账号用户博客',
27
+ docs: 'https://docs.rsshub.app/programming.html#kai-yuan-zhong-guo',
28
+ source: ['/u/:uid'],
29
+ target: '/oschina/u/:uid',
30
+ },
31
+ ],
32
+ },
33
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = (router) => {
2
+ router.get('/news/:category?', require('./news'));
3
+ router.get('/topic/:topic', require('./topic'));
4
+ router.get('/u/:uid', require('./user'));
5
+ router.get('/user/:id', require('./user'));
6
+ };
@@ -0,0 +1,53 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
3
+ const timezone = require('@/utils/timezone');
4
+ const cheerio = require('cheerio');
5
+
6
+ async function load(link) {
7
+ const res = await got(link);
8
+ const content = cheerio.load(res.data);
9
+ return content;
10
+ }
11
+
12
+ module.exports = async (ctx) => {
13
+ const topic = ctx.params.topic;
14
+ const topicUrl = `https://www.oschina.net/question/topic/${topic}?show=time`;
15
+
16
+ const $ = await load(topicUrl);
17
+ const topicName = $('.topic-info > .topic-header > h3').text();
18
+ const list = $('#questionList .question-item')
19
+ .toArray()
20
+ .map((item) => {
21
+ item = $(item);
22
+ const date = item.find('.extra > .list > .item:nth-of-type(2)').text();
23
+ return {
24
+ title: item.find('.header').text(),
25
+ description: item.find('.description').html(),
26
+ link: item.find('.header').attr('href'),
27
+ author: item.find('.extra > .list > .item:nth-of-type(1)').text(),
28
+ pubDate: timezone(/\//.test(date) ? parseDate(date, ['YYYY/MM/DD HH:mm', 'MM/DD HH:mm']) : parseRelativeDate(date), +8),
29
+ };
30
+ });
31
+
32
+ const resultItem = await Promise.all(
33
+ list.map((item) =>
34
+ ctx.cache.tryGet(item.link, async () => {
35
+ try {
36
+ const content = await load(item.link);
37
+ content('.ad-wrap').remove();
38
+ item.description = content('#articleContent').html();
39
+ } catch (e) {
40
+ // 403
41
+ }
42
+ return item;
43
+ })
44
+ )
45
+ );
46
+
47
+ ctx.state.data = {
48
+ title: `开源中国-${topicName}`,
49
+ description: $('.topic-introduction').text(),
50
+ link: topicUrl,
51
+ item: resultItem,
52
+ };
53
+ };
@@ -0,0 +1,50 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
4
+ const timezone = require('@/utils/timezone');
5
+
6
+ module.exports = async (ctx) => {
7
+ const { id, uid } = ctx.params;
8
+ const res = id ? await got(`https://my.oschina.net/${id}`) : await got(`https://my.oschina.net/u/${uid}`);
9
+ const $ = cheerio.load(res.data);
10
+
11
+ const author = $('.user-name .name').text();
12
+ const list = $('#newestBlogList .blog-item')
13
+ .toArray()
14
+ .map((item) => {
15
+ item = $(item);
16
+ const date = item.find('.extra div .item:nth-of-type(2)').text();
17
+ const accessible = !item.find('div.label[data-tooltip=审核中]').length;
18
+ item.find('.label').remove();
19
+ return {
20
+ title: item.find('.content a.header').text(),
21
+ description: item.find('.description p').text(),
22
+ link: item.find('a.header').attr('href'),
23
+ pubDate: timezone(/\//.test(date) ? parseDate(date, ['YYYY/MM/DD HH:mm', 'MM/DD HH:mm']) : parseRelativeDate(date), +8),
24
+ author,
25
+ accessible,
26
+ };
27
+ });
28
+
29
+ const resultItem = await Promise.all(
30
+ list.map((item) =>
31
+ ctx.cache.tryGet(item.link, async () => {
32
+ if (item.accessible) {
33
+ const detail = await got(item.link);
34
+ const content = cheerio.load(detail.data);
35
+
36
+ item.description = content('.article-detail').html();
37
+ }
38
+ delete item.accessible;
39
+ return item;
40
+ })
41
+ )
42
+ );
43
+
44
+ ctx.state.data = {
45
+ title: author + '的博客',
46
+ description: $('.user-text .user-signature').text(),
47
+ link: `https://my.oschina.net/${id ? id : uid}`,
48
+ item: resultItem,
49
+ };
50
+ };
@@ -0,0 +1,23 @@
1
+ const got = require('@/utils/got');
2
+ const { baseUrl, getPlurk } = require('./utils');
3
+
4
+ module.exports = async (ctx) => {
5
+ const { data: apiResponse } = await got(`${baseUrl}/Stats/getAnonymousPlurks`, {
6
+ searchParams: {
7
+ offset: 0,
8
+ limit: ctx.query.limit ? Number(ctx.query.limit) : 200,
9
+ },
10
+ });
11
+
12
+ delete apiResponse.pids;
13
+ delete apiResponse.count;
14
+
15
+ const items = await Promise.all(Object.values(apiResponse).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, 'ಠ_ಠ', ctx.cache.tryGet)));
16
+
17
+ ctx.state.data = {
18
+ title: 'Anonymous - Plurk',
19
+ image: 'https://s.plurk.com/2c1574c02566f3b06e91.png',
20
+ link: `${baseUrl}/anonymous`,
21
+ item: items,
22
+ };
23
+ };
@@ -0,0 +1,20 @@
1
+ const got = require('@/utils/got');
2
+ const { baseUrl, getPlurk } = require('./utils');
3
+
4
+ module.exports = async (ctx) => {
5
+ const { data: apiResponse } = await got(`${baseUrl}/hotlinks/getLinks`, {
6
+ searchParams: {
7
+ offset: 0,
8
+ count: ctx.query.limit ? Number(ctx.query.limit) : 30,
9
+ },
10
+ });
11
+
12
+ const items = await Promise.all(apiResponse.map((item) => getPlurk(item.link_url.startsWith('https://www.plurk.com/p/') ? item.link_url : `plurk:${item.link_url}`, item, null, ctx.cache.tryGet)));
13
+
14
+ ctx.state.data = {
15
+ title: `Hot Links - Plurk`,
16
+ image: 'https://s.plurk.com/2c1574c02566f3b06e91.png',
17
+ link: `${baseUrl}/hotlinks`,
18
+ item: items,
19
+ };
20
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ '/anonymous': ['TonyRL'],
3
+ '/hotlinks': ['TonyRL'],
4
+ '/news/:lang?': ['TonyRL'],
5
+ '/search/:keyword': ['TonyRL'],
6
+ '/top/:category?/:lang?': ['TonyRL'],
7
+ '/topic/:topic': ['TonyRL'],
8
+ '/user/:user': ['TonyRL'],
9
+ };
@@ -0,0 +1,23 @@
1
+ const got = require('@/utils/got');
2
+ const { baseUrl, fetchFriends, getPlurk } = require('./utils');
3
+
4
+ module.exports = async (ctx) => {
5
+ const { lang = 'en' } = ctx.params;
6
+ const { data: apiResponse } = await got(`${baseUrl}/PlurkTop/fetchOfficialPlurks`, {
7
+ searchParams: {
8
+ lang,
9
+ },
10
+ });
11
+
12
+ const userIds = apiResponse.map((item) => item.user_id);
13
+ const names = await fetchFriends(userIds);
14
+
15
+ const items = await Promise.all(apiResponse.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, ctx.cache.tryGet)));
16
+
17
+ ctx.state.data = {
18
+ title: 'Plurk News - Plurk',
19
+ image: 'https://s.plurk.com/2c1574c02566f3b06e91.png',
20
+ link: `${baseUrl}/news`,
21
+ item: items,
22
+ };
23
+ };
@@ -0,0 +1,56 @@
1
+ module.exports = {
2
+ 'plurk.com': {
3
+ _name: 'Plurk',
4
+ '.': [
5
+ {
6
+ title: '話題',
7
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
8
+ source: ['/topic/:topic'],
9
+ target: '/plurk/topic/:topic',
10
+ },
11
+ {
12
+ title: '話題排行榜',
13
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
14
+ source: ['/top'],
15
+ target: (_, url) => {
16
+ const hash = new URL(url).hash;
17
+ return `/plurk/top/${hash ? hash.slice(1) : 'topReplurks'}`;
18
+ },
19
+ },
20
+ {
21
+ title: '偷偷說',
22
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
23
+ source: ['/anonymous'],
24
+ target: '/plurk/anonymous',
25
+ },
26
+ {
27
+ title: '搜尋',
28
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
29
+ source: ['/search'],
30
+ target: (_, url) => `/plurk/search/${new URL(url).searchParams.get('q')}`,
31
+ },
32
+ {
33
+ title: '最近分享',
34
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
35
+ source: ['/hotlinks'],
36
+ target: '/plurk/hotlinks',
37
+ },
38
+ {
39
+ title: '噗浪消息',
40
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
41
+ source: ['/news'],
42
+ target: '/plurk/news',
43
+ },
44
+ {
45
+ title: '用戶',
46
+ docs: 'https://docs.rsshub.app/social-media.html#plurk',
47
+ source: ['/:user'],
48
+ target: (params) => {
49
+ if (params.user !== 'portal' && params.user !== 'top' && params.user !== 'anonymous' && params.user !== 'search' && params.user !== 'hotlinks' && params.user !== 'news') {
50
+ return `/plurk/user/${params.user}`;
51
+ }
52
+ },
53
+ },
54
+ ],
55
+ },
56
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = (router) => {
2
+ router.get('/anonymous', require('./anonymous'));
3
+ router.get('/hotlinks', require('./hotlinks'));
4
+ router.get('/news/:lang?', require('./news'));
5
+ router.get('/search/:keyword', require('./search'));
6
+ router.get('/top/:category?/:lang?', require('./top'));
7
+ router.get('/topic/:topic', require('./topic'));
8
+ router.get('/user/:user', require('./user'));
9
+ };
@@ -0,0 +1,27 @@
1
+ const got = require('@/utils/got');
2
+ const dayjs = require('dayjs');
3
+ const { baseUrl, getPlurk } = require('./utils');
4
+
5
+ module.exports = async (ctx) => {
6
+ const { keyword } = ctx.params;
7
+ const { data: apiResponse } = await got.post(`${baseUrl}/Search/search2`, {
8
+ searchParams: {
9
+ query: keyword,
10
+ start_date: dayjs().subtract(1, 'year').format('YYYY/MM'),
11
+ end_date: dayjs().format('YYYY/MM'),
12
+ },
13
+ });
14
+
15
+ const users = apiResponse.users;
16
+ const plurks = apiResponse.plurks;
17
+
18
+ const items = await Promise.all(plurks.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, users[item.user_id].display_name, ctx.cache.tryGet)));
19
+
20
+ ctx.state.data = {
21
+ title: `Search "${keyword}" - Plurk`,
22
+ description: 'Search messages on Plurk',
23
+ image: 'https://s.plurk.com/e8266f512246cdbc2721.jpg',
24
+ link: `${baseUrl}/search?q=${encodeURIComponent(keyword)}`,
25
+ item: items,
26
+ };
27
+ };