rsshub 1.0.0-master.d2b1df9 → 1.0.0-master.d2eb1ac

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 (73) 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/bilibili/collection.js +34 -0
  5. package/lib/v2/bilibili/maintainer.js +1 -0
  6. package/lib/v2/bilibili/radar.js +9 -0
  7. package/lib/v2/bilibili/router.js +1 -0
  8. package/lib/v2/china/maintainer.js +4 -0
  9. package/lib/v2/china/news/highlights/news.js +40 -0
  10. package/lib/v2/china/news/military/news.js +31 -0
  11. package/lib/v2/china/radar.js +21 -0
  12. package/lib/v2/china/router.js +4 -0
  13. package/lib/v2/csdn/blog.js +39 -0
  14. package/lib/v2/csdn/maintainer.js +3 -0
  15. package/lib/v2/csdn/radar.js +13 -0
  16. package/lib/v2/csdn/router.js +3 -0
  17. package/lib/v2/douyu/post.js +9 -2
  18. package/lib/v2/github/comments.js +3 -4
  19. package/lib/v2/iwara/maintainer.js +1 -0
  20. package/lib/v2/iwara/radar.js +6 -0
  21. package/lib/v2/iwara/router.js +1 -0
  22. package/lib/v2/iwara/subscriptions.js +48 -0
  23. package/lib/v2/iwara/templates/subscriptions.art +1 -0
  24. package/lib/v2/leetcode/dailyquestion-solution-cn.js +183 -0
  25. package/lib/v2/leetcode/dailyquestion-solution-en.js +213 -0
  26. package/lib/v2/leetcode/maintainer.js +1 -0
  27. package/lib/v2/leetcode/radar.js +12 -0
  28. package/lib/v2/leetcode/router.js +2 -0
  29. package/lib/v2/lovelive-anime/maintainer.js +3 -0
  30. package/lib/v2/lovelive-anime/news.js +56 -0
  31. package/lib/v2/lovelive-anime/radar.js +13 -0
  32. package/lib/v2/lovelive-anime/router.js +3 -0
  33. package/lib/v2/lovelive-anime/templates/description.art +1 -0
  34. package/lib/v2/nua/gra.js +56 -0
  35. package/lib/v2/nua/maintainer.js +3 -0
  36. package/lib/v2/nua/radar.js +13 -0
  37. package/lib/v2/nua/router.js +3 -0
  38. package/lib/v2/oschina/maintainer.js +6 -0
  39. package/lib/{routes → v2}/oschina/news.js +35 -39
  40. package/lib/v2/oschina/radar.js +33 -0
  41. package/lib/v2/oschina/router.js +6 -0
  42. package/lib/v2/oschina/topic.js +53 -0
  43. package/lib/v2/oschina/user.js +50 -0
  44. package/lib/v2/segmentfault/blogs.js +38 -0
  45. package/lib/v2/segmentfault/maintainer.js +1 -0
  46. package/lib/v2/segmentfault/radar.js +8 -2
  47. package/lib/v2/segmentfault/router.js +1 -0
  48. package/lib/v2/sensortower/blog.js +69 -0
  49. package/lib/v2/sensortower/maintainer.js +3 -0
  50. package/lib/v2/sensortower/radar.js +13 -0
  51. package/lib/v2/sensortower/router.js +3 -0
  52. package/lib/v2/sensortower/templates/description.art +9 -0
  53. package/lib/v2/taptap/templates/imagePost.art +3 -0
  54. package/lib/v2/taptap/templates/videoPost.art +2 -1
  55. package/lib/v2/taptap/topic.js +33 -27
  56. package/lib/v2/taptap/utils.js +13 -8
  57. package/lib/v2/test/index.js +15 -0
  58. package/lib/v2/trending/allTrending.js +46 -19
  59. package/lib/v2/trending/templates/content.art +1 -0
  60. package/lib/v2/zuvio/boards.js +14 -0
  61. package/lib/v2/zuvio/radar.js +13 -0
  62. package/lib/v2/zuvio/router.js +4 -0
  63. package/lib/v2/zuvio/student5.js +58 -0
  64. package/lib/v2/zuvio/templates/img.art +2 -0
  65. package/lib/v2/zuvio/templates/link.art +7 -0
  66. package/lib/v2/zuvio/templates/ref_article.art +8 -0
  67. package/lib/v2/zuvio/templates/rss.art +1 -0
  68. package/lib/v2/zuvio/templates/youtube.art +2 -0
  69. package/lib/v2/zuvio/utils.js +61 -0
  70. package/package.json +9 -10
  71. package/lib/routes/oschina/topic.js +0 -54
  72. package/lib/routes/oschina/u.js +0 -57
  73. package/lib/routes/oschina/user.js +0 -57
package/lib/config.js CHANGED
@@ -178,6 +178,9 @@ const calculateValue = () => {
178
178
  password: envs.IG_PASSWORD,
179
179
  proxy: envs.IG_PROXY,
180
180
  },
181
+ iwara: {
182
+ cookie: envs.IWARA_COOKIE,
183
+ },
181
184
  lastfm: {
182
185
  api_key: envs.LASTFM_API_KEY,
183
186
  },
@@ -56,6 +56,9 @@ module.exports = function (app) {
56
56
  app.context.cache = {
57
57
  ...cacheModule,
58
58
  tryGet: async (key, getValueFunc, maxAge = config.cache.contentExpire, refresh = true) => {
59
+ if (typeof key !== 'string') {
60
+ throw Error('Cache key must be a string');
61
+ }
59
62
  let v = await get(key, refresh);
60
63
  if (!v) {
61
64
  v = await getValueFunc();
package/lib/router.js CHANGED
@@ -396,11 +396,11 @@ router.get('/gwern/:category', lazyloadRouteHandler('./routes/gwern/category'));
396
396
  // LinkedKeeper
397
397
  router.get('/linkedkeeper/:type/:id?', lazyloadRouteHandler('./routes/linkedkeeper/index'));
398
398
 
399
- // 开源中国
400
- router.get('/oschina/news/:category?', lazyloadRouteHandler('./routes/oschina/news'));
401
- router.get('/oschina/user/:id', lazyloadRouteHandler('./routes/oschina/user'));
402
- router.get('/oschina/u/:id', lazyloadRouteHandler('./routes/oschina/u'));
403
- router.get('/oschina/topic/:topic', lazyloadRouteHandler('./routes/oschina/topic'));
399
+ // 开源中国 migrated to v2
400
+ // router.get('/oschina/news/:category?', lazyloadRouteHandler('./routes/oschina/news'));
401
+ // router.get('/oschina/user/:id', lazyloadRouteHandler('./routes/oschina/user'));
402
+ // router.get('/oschina/u/:id', lazyloadRouteHandler('./routes/oschina/u'));
403
+ // router.get('/oschina/topic/:topic', lazyloadRouteHandler('./routes/oschina/topic'));
404
404
 
405
405
  // MIT Technology Review
406
406
  router.get('/technologyreview', lazyloadRouteHandler('./routes/technologyreview/index'));
@@ -0,0 +1,34 @@
1
+ const got = require('@/utils/got');
2
+ const cache = require('./cache');
3
+ const utils = require('./utils');
4
+ const { parseDate } = require('@/utils/parse-date');
5
+
6
+ module.exports = async (ctx) => {
7
+ const uid = ctx.params.uid;
8
+ const sid = ctx.params.sid;
9
+ const disableEmbed = ctx.params.disableEmbed;
10
+ const [name, face] = await cache.getUsernameAndFaceFromUID(ctx, uid);
11
+ const response = await got({
12
+ method: 'get',
13
+ url: `https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=false&page_num=1&page_size=30`,
14
+ headers: {
15
+ Referer: `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`,
16
+ },
17
+ });
18
+ const data = response.data;
19
+
20
+ ctx.state.data = {
21
+ title: `${name}的${data.data.meta.name}`,
22
+ link: `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`,
23
+ description: `${name} 的 bilibili 合集`,
24
+ logo: face,
25
+ icon: face,
26
+ item: data.data.archives.map((item) => ({
27
+ title: item.title,
28
+ description: `${!disableEmbed ? `<br><br>${utils.iframe(item.aid)}` : ''}<br><img src="${item.pic}">`,
29
+ pubDate: parseDate(item.pubdate * 1000),
30
+ link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.aid}`,
31
+ author: name,
32
+ })),
33
+ };
34
+ };
@@ -4,6 +4,7 @@ module.exports = {
4
4
  '/blackboard': ['Qixingchen'],
5
5
  '/bangumi/:seasonid': ['DIYgod'],
6
6
  '/bangumi/media/:mediaid': ['DIYgod'],
7
+ '/collection/:uid/:sid/:disableEmbed?': ['shininome'],
7
8
  '/fav/:uid/:fid/:disableEmbed?': ['Qixingchen'],
8
9
  '/followings/article/:uid': ['woshiluo'],
9
10
  '/followings/dynamic/:uid/:disableEmbed?': ['TigerCubDen'],
@@ -90,6 +90,15 @@ module.exports = {
90
90
  source: '/:uid',
91
91
  target: '/bilibili/user/bangumi/:uid',
92
92
  },
93
+ {
94
+ title: '当前合集',
95
+ docs: 'https://docs.rsshub.app/social-media.html#bilibili',
96
+ source: '/:uid/channel/collectiondetail',
97
+ target: (params, url) => {
98
+ const sid = new URL(url).searchParams.get('sid');
99
+ return `/bilibili/collection/:uid/${sid}`;
100
+ },
101
+ },
93
102
  ],
94
103
  manga: [
95
104
  {
@@ -4,6 +4,7 @@ module.exports = (router) => {
4
4
  router.get('/blackboard', require('./blackboard'));
5
5
  router.get('/bangumi/:seasonid', require('./bangumi')); // 弃用
6
6
  router.get('/bangumi/media/:mediaid', require('./bangumi'));
7
+ router.get('/collection/:uid/:sid/:disableEmbed?', require('./collection'));
7
8
  router.get('/fav/:uid/:fid/:disableEmbed?', require('./fav'));
8
9
  router.get('/followings/article/:uid', require('./followings_article'));
9
10
  router.get('/followings/dynamic/:uid/:disableEmbed?', require('./followings_dynamic'));
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '/news/military': ['jiaaoMario'],
3
+ '/news/:category?': ['jiaaoMario'],
4
+ };
@@ -0,0 +1,40 @@
1
+ const cheerio = require('cheerio');
2
+ const got = require('@/utils/got');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ const CATEGORY_MAP = {
6
+ domestic: 'domestic',
7
+ international: 'international',
8
+ social: 'social',
9
+ news100: 'news100',
10
+ };
11
+
12
+ module.exports = async (ctx) => {
13
+ const baseUrl = 'https://news.china.com';
14
+ const category = CATEGORY_MAP[ctx.params.category] ?? CATEGORY_MAP.domestic;
15
+ const websiteUrl = `${baseUrl}/${category}`;
16
+ const response = await got(websiteUrl);
17
+ const data = response.data;
18
+ const $ = cheerio.load(data);
19
+ const categoryTitle = $('.wp_title').text();
20
+ const news = $('.item_list li');
21
+ ctx.state.data = {
22
+ title: `中华网-${categoryTitle}新闻`,
23
+ link: websiteUrl,
24
+ item:
25
+ news &&
26
+ news
27
+ .map((_, item) => {
28
+ item = $(item);
29
+ return {
30
+ title: item.find('.item_title a').text(),
31
+ author: item.find('.item_source').text(),
32
+ category: `${categoryTitle}新闻`,
33
+ pubDate: parseDate(item.find('.item_time').text()),
34
+ description: item.find('.item_title a').text(),
35
+ link: item.find('li a').attr('href'),
36
+ };
37
+ })
38
+ .get(),
39
+ };
40
+ };
@@ -0,0 +1,31 @@
1
+ const cheerio = require('cheerio');
2
+ const got = require('@/utils/got');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const websiteUrl = 'https://military.china.com/news/';
7
+ const response = await got(websiteUrl);
8
+ const data = response.data;
9
+ const $ = cheerio.load(data);
10
+ const commonList = $('.listItem');
11
+
12
+ ctx.state.data = {
13
+ title: '中华网-军事新闻',
14
+ link: 'https://military.china.com/news/',
15
+ item:
16
+ commonList &&
17
+ commonList
18
+ .map((_, item) => {
19
+ item = $(item);
20
+ return {
21
+ title: item.find('.tit a').text(),
22
+ author: '中华网军事',
23
+ category: '中华网军事',
24
+ pubDate: parseDate(item.find('.time').text()),
25
+ description: item.find('.tag').text(),
26
+ link: item.find('.tit a').attr('href'),
27
+ };
28
+ })
29
+ .get(),
30
+ };
31
+ };
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ 'china.com': {
3
+ _name: '中华网',
4
+ military: [
5
+ {
6
+ title: '军事新闻',
7
+ docs: 'https://docs.rsshub.app/new-media.html#zhong-hua-wang',
8
+ source: '/news',
9
+ target: '/china/news/military',
10
+ },
11
+ ],
12
+ news: [
13
+ {
14
+ title: '时事新闻',
15
+ docs: 'https://docs.rsshub.app/new-media.html#zhong-hua-wang',
16
+ source: '/:category',
17
+ target: '/china/news/:category?',
18
+ },
19
+ ],
20
+ },
21
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = (router) => {
2
+ router.get('/news/military', require('./news/military/news.js'));
3
+ router.get('/news/:category?', require('./news/highlights/news.js'));
4
+ };
@@ -0,0 +1,39 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const rssParser = require('@/utils/rss-parser');
4
+
5
+ module.exports = async (ctx) => {
6
+ const user = ctx.params.user;
7
+
8
+ const rootUrl = 'https://blog.csdn.net';
9
+ const blogUrl = `${rootUrl}/${user}`;
10
+ const rssUrl = blogUrl + '/rss/list';
11
+
12
+ const feed = await rssParser.parseURL(rssUrl);
13
+
14
+ const items = await Promise.all(
15
+ feed.items.map((item) =>
16
+ ctx.cache.tryGet(item.link, async () => {
17
+ const response = await got({
18
+ method: 'get',
19
+ url: item.link,
20
+ });
21
+
22
+ const $ = cheerio.load(response.data);
23
+
24
+ const description = $('#content_views').html();
25
+
26
+ return {
27
+ ...item,
28
+ description,
29
+ };
30
+ })
31
+ )
32
+ );
33
+
34
+ ctx.state.data = {
35
+ ...feed,
36
+ title: `${feed.title} - CSDN博客`,
37
+ item: items,
38
+ };
39
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/blog': ['Jkker'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'csdn.net': {
3
+ _name: 'CSDN',
4
+ blog: [
5
+ {
6
+ title: '博客',
7
+ docs: 'https://docs.rsshub.app/blog.html#csdn',
8
+ source: ['/:user'],
9
+ target: '/csdn/blog/:user',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/blog/:user', require('./blog'));
3
+ };
@@ -16,9 +16,16 @@ module.exports = async (ctx) => {
16
16
  });
17
17
 
18
18
  const data = detailResponse.data.data;
19
- const apiUrl = `${rootUrl}/wbapi/web/post/comments/${id}?group_id=${data.group_id}&sink=1&page=1`;
19
+ let apiUrl = `${rootUrl}/wbapi/web/post/comments/${id}?group_id=${data.group_id}&sink=1&page=1`;
20
20
 
21
- const response = await got({
21
+ let response = await got({
22
+ method: 'get',
23
+ url: apiUrl,
24
+ });
25
+
26
+ apiUrl = `${rootUrl}/wbapi/web/post/comments/${id}?group_id=${data.group_id}&sink=1&page=${response.data.page_total}`;
27
+
28
+ response = await got({
22
29
  method: 'get',
23
30
  url: apiUrl,
24
31
  });
@@ -29,15 +29,13 @@ module.exports = async (ctx) => {
29
29
  Accept: 'application/vnd.github.v3+json',
30
30
  };
31
31
 
32
- const response = await got({
33
- url: `${apiUrl}/repos/${user}/${repo}/issues/${number}`,
32
+ const response = await got(`${apiUrl}/repos/${user}/${repo}/issues/${number}`, {
34
33
  headers,
35
34
  });
36
35
  const issue = response.data;
37
36
  const type = issue.pull_request ? 'pull' : 'issue';
38
37
 
39
- const timelineResponse = await got({
40
- url: issue.timeline_url,
38
+ const timelineResponse = await got(issue.timeline_url, {
41
39
  headers,
42
40
  searchParams: {
43
41
  per_page: limit,
@@ -81,6 +79,7 @@ module.exports = async (ctx) => {
81
79
  author: item.actor.login,
82
80
  pubDate: parseDate(item.created_at),
83
81
  guid: `${item.actor.login} ${item.event} on ${user}/${repo}: ${typeDict[type].title} #${issue.number} on ${item.created_at}`,
82
+ link: `${item.actor.login} ${item.event} on ${user}/${repo}: ${typeDict[type].title} #${issue.number} on ${item.created_at}`,
84
83
  });
85
84
  break;
86
85
  case 'renamed':
@@ -1,3 +1,4 @@
1
1
  module.exports = {
2
2
  '/users/:username?/:type?': ['Fatpandac'],
3
+ '/subscriptions': ['FeCCC'],
3
4
  };
@@ -14,6 +14,12 @@ module.exports = {
14
14
  source: '/users/:username',
15
15
  target: '/iwara/users/:username?/image',
16
16
  },
17
+ {
18
+ title: '用户订阅列表',
19
+ docs: 'https://docs.rsshub.app/anime.html#iwara',
20
+ source: '',
21
+ target: '/iwara/subscriptions',
22
+ },
17
23
  ],
18
24
  },
19
25
  };
@@ -1,3 +1,4 @@
1
1
  module.exports = function (router) {
2
2
  router.get('/users/:username?/:type?', require('./index'));
3
+ router.get('/subscriptions', require('./subscriptions'));
3
4
  };
@@ -0,0 +1,48 @@
1
+ const got = require('@/utils/got');
2
+ const config = require('@/config').value;
3
+ const cheerio = require('cheerio');
4
+ const { art } = require('@/utils/render');
5
+ const path = require('path');
6
+
7
+ module.exports = async (ctx) => {
8
+ const rootUrl = `https://ecchi.iwara.tv/subscriptions`;
9
+ const cookie = config.iwara.cookie;
10
+
11
+ if (cookie === undefined) {
12
+ throw Error('Iwara subscription RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
13
+ }
14
+
15
+ const response = await got({
16
+ method: 'get',
17
+ url: rootUrl,
18
+ headers: {
19
+ Cookie: cookie,
20
+ },
21
+ });
22
+ const $ = cheerio.load(response.data);
23
+ const username = $('a.btn.btn-info.btn-sm.user').text().trim();
24
+ const list = $('div.views-column');
25
+
26
+ const items = list
27
+ .map((_, item) => {
28
+ const imageUrl = 'https:' + $(item).find('img').attr('src');
29
+ const type = $(item).find('div.field').hasClass('field-type-video') ? 'Video' : 'Image';
30
+ return {
31
+ title: $(item).find('h3.title').text(),
32
+ author: username,
33
+ link: rootUrl + $(item).find('h3.title > a').attr('href'),
34
+ category: type,
35
+ description: art(path.join(__dirname, 'templates/subscriptions.art'), {
36
+ type,
37
+ imageUrl,
38
+ }),
39
+ };
40
+ })
41
+ .get();
42
+
43
+ ctx.state.data = {
44
+ title: `${username}'s iwara Subscription`,
45
+ link: rootUrl,
46
+ item: items,
47
+ };
48
+ };
@@ -0,0 +1 @@
1
+ <h3>{{ type }}</h3><br><img src="{{ imageUrl }}">
@@ -0,0 +1,183 @@
1
+ const got = require('@/utils/got');
2
+ const showdown = require('showdown');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const timezone = require('@/utils/timezone');
5
+ module.exports = async (ctx) => {
6
+ const baseurl = `https://leetcode.cn`;
7
+ const url = `${baseurl}/graphql/`;
8
+ const headers = {
9
+ 'content-type': 'application/json',
10
+ };
11
+ const emoji = {
12
+ Medium: '🟡',
13
+ Easy: '🟢',
14
+ Hard: '🔴',
15
+ };
16
+ // 获取每日一题
17
+ const data = (
18
+ await got({
19
+ method: 'post',
20
+ url,
21
+ json: {
22
+ operationName: 'questionOfToday',
23
+ query: `query questionOfToday {
24
+ todayRecord {
25
+ date
26
+ userStatus
27
+ question {
28
+ questionId
29
+ frontendQuestionId: questionFrontendId
30
+ difficulty
31
+ title
32
+ titleCn: translatedTitle
33
+ titleSlug
34
+ }
35
+ }
36
+ }`,
37
+ variables: {},
38
+ },
39
+ headers,
40
+ })
41
+ ).data.data;
42
+ const questionTitle = data.todayRecord[0].question.titleSlug;
43
+ const questionUrl = `${baseurl}/problems/${questionTitle}/`;
44
+
45
+ // 获取题目内容
46
+ const question = (
47
+ await got({
48
+ method: 'post',
49
+ url,
50
+ json: {
51
+ operationName: 'questionData',
52
+ query: `query questionData($titleSlug: String!) {
53
+ question(titleSlug: $titleSlug) {
54
+ questionId
55
+ questionFrontendId
56
+ categoryTitle
57
+ boundTopicId
58
+ title
59
+ titleSlug
60
+ content
61
+ translatedTitle
62
+ translatedContent
63
+ isPaidOnly
64
+ difficulty
65
+ likes
66
+ }
67
+ }`,
68
+ variables: {
69
+ titleSlug: questionTitle,
70
+ },
71
+ },
72
+ headers,
73
+ })
74
+ ).data.data.question;
75
+ const diffEmoji = emoji[question.difficulty] || '';
76
+ // 获取题解(点赞前3)
77
+ const articles = (
78
+ await got({
79
+ method: 'post',
80
+ url,
81
+ json: {
82
+ operationName: 'questionSolutionArticles',
83
+ query: `query questionSolutionArticles($questionSlug: String!, $skip: Int, $first: Int, $orderBy: SolutionArticleOrderBy, $userInput: String, $tagSlugs: [String!]) {
84
+ questionSolutionArticles(questionSlug: $questionSlug, skip: $skip, first: $first, orderBy: $orderBy, userInput: $userInput, tagSlugs: $tagSlugs) {
85
+ totalNum
86
+ edges {
87
+ node {
88
+ ...solutionArticle
89
+ __typename
90
+ }
91
+ __typename
92
+ }
93
+ __typename
94
+ }
95
+ }
96
+ fragment solutionArticle on SolutionArticleNode {
97
+ uuid
98
+ title
99
+ slug
100
+ createdAt
101
+ thumbnail
102
+ author {
103
+ username
104
+ }
105
+ summary
106
+ }`,
107
+ variables: {
108
+ questionSlug: questionTitle,
109
+ first: 3,
110
+ skip: 0,
111
+ orderBy: 'MOST_UPVOTE',
112
+ },
113
+ },
114
+ headers,
115
+ })
116
+ ).data.data.questionSolutionArticles.edges;
117
+ // 获取题解内容
118
+ const articleContent = (
119
+ await Promise.all(
120
+ articles.map((art) =>
121
+ got({
122
+ method: 'post',
123
+ url,
124
+ json: {
125
+ operationName: 'solutionDetailArticle',
126
+ query: `query solutionDetailArticle($slug: String!, $orderBy: SolutionArticleOrderBy!) {
127
+ solutionArticle(slug: $slug, orderBy: $orderBy) {
128
+ ...solutionArticle
129
+ content
130
+ question {
131
+ questionTitleSlug
132
+ __typename
133
+ }
134
+ }
135
+ }
136
+ fragment solutionArticle on SolutionArticleNode {
137
+ uuid
138
+ title
139
+ slug
140
+ createdAt
141
+ thumbnail
142
+ author {
143
+ username
144
+ }
145
+ summary
146
+ }`,
147
+ variables: {
148
+ slug: art.node.slug,
149
+ orderBy: 'DEFAULT',
150
+ },
151
+ },
152
+ headers,
153
+ })
154
+ )
155
+ )
156
+ ).map((v) => v.data.data.solutionArticle);
157
+ const converter = new showdown.Converter();
158
+ const handleText = (s) => {
159
+ // 处理多语言代码展示问题
160
+ s = s.replace(/(```)([a-zA-Z0-9-+#]+)\s*?(\[.*?\])?\n/g, '\r\n###$2\r\n$1$2\r\n');
161
+ return s;
162
+ };
163
+ ctx.state.data = {
164
+ title: 'LeetCode 每日一题题解',
165
+ description: 'LeetCode 每日一题题解',
166
+ link: questionUrl,
167
+ item: [
168
+ {
169
+ title: `每日一题-${question.translatedTitle}${diffEmoji}`,
170
+ link: questionUrl,
171
+ description: question.translatedContent,
172
+ pubDate: timezone(parseDate(data.todayRecord[0].date), +8),
173
+ },
174
+ ...articleContent.map((art, i) => ({
175
+ title: art.title,
176
+ link: `${questionUrl}/solution/${art.slug}`,
177
+ description: converter.makeHtml(handleText(art.content)),
178
+ pubDate: timezone(parseDate(articles[i].node.createdAt), +8),
179
+ author: art.author.username,
180
+ })),
181
+ ],
182
+ };
183
+ };