rsshub 1.0.0-master.c183692 → 1.0.0-master.c1913c8

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 (103) hide show
  1. package/README.md +6 -9
  2. package/lib/config.ts +18 -0
  3. package/lib/errors/index.tsx +1 -1
  4. package/lib/middleware/logger.ts +2 -2
  5. package/lib/routes/abc/index.ts +2 -2
  6. package/lib/routes/apnews/api.ts +6 -1
  7. package/lib/routes/apnews/rss.ts +1 -1
  8. package/lib/routes/apnews/sitemap.ts +2 -1
  9. package/lib/routes/apnews/topics.ts +2 -2
  10. package/lib/routes/asus/bios.ts +39 -6
  11. package/lib/routes/bilibili/bilibili-recommend.ts +42 -0
  12. package/lib/routes/bilibili/cache.ts +22 -0
  13. package/lib/routes/bilibili/dynamic.ts +101 -97
  14. package/lib/routes/bilibili/followings-video.ts +9 -3
  15. package/lib/routes/bilibili/utils.ts +5 -0
  16. package/lib/routes/bilibili/video.ts +2 -1
  17. package/lib/routes/bitget/announcement.ts +200 -0
  18. package/lib/routes/bitget/namespace.ts +6 -0
  19. package/lib/routes/bitget/type.ts +26 -0
  20. package/lib/routes/bjp/apod.ts +4 -2
  21. package/lib/routes/bupt/jwc.ts +130 -0
  22. package/lib/routes/ccfa/index.ts +216 -0
  23. package/lib/routes/ccfa/namespace.ts +8 -0
  24. package/lib/routes/ccfa/templates/description.art +7 -0
  25. package/lib/routes/devtrium/namespace.ts +6 -0
  26. package/lib/routes/devtrium/posts.ts +55 -0
  27. package/lib/routes/discourse/official.ts +55 -0
  28. package/lib/routes/dockerhub/utils.ts +4 -3
  29. package/lib/routes/douban/movie/coming.ts +68 -0
  30. package/lib/routes/douban/templates/movie_coming.art +27 -0
  31. package/lib/routes/follow/profile.ts +35 -5
  32. package/lib/routes/github/comments.ts +32 -30
  33. package/lib/routes/gov/cn/namespace.ts +8 -0
  34. package/lib/routes/gov/{news → cn/news}/index.ts +11 -7
  35. package/lib/routes/gov/ndrc/fggz.ts +637 -2
  36. package/lib/routes/gov/ndrc/namespace.ts +8 -0
  37. package/lib/routes/gov/ndrc/xwdt.ts +28 -8
  38. package/lib/routes/gov/ndrc/zfxxgk/articles.ts +73 -0
  39. package/lib/routes/hpoi/all.ts +3 -2
  40. package/lib/routes/hpoi/character.ts +3 -2
  41. package/lib/routes/hpoi/work.ts +3 -2
  42. package/lib/routes/jjwxc/book.ts +18 -14
  43. package/lib/routes/lofter/collection.ts +87 -0
  44. package/lib/routes/malaysiakini/index.ts +179 -0
  45. package/lib/routes/malaysiakini/namespace.ts +11 -0
  46. package/lib/routes/mastodon/acct.ts +4 -3
  47. package/lib/routes/mastodon/timeline-local.ts +3 -2
  48. package/lib/routes/mastodon/timeline-remote.ts +3 -2
  49. package/lib/routes/meishichina/index.ts +1997 -0
  50. package/lib/routes/meishichina/namespace.ts +8 -0
  51. package/lib/routes/oct0pu5/namespace.ts +10 -0
  52. package/lib/routes/oct0pu5/rss.ts +48 -0
  53. package/lib/routes/pconline/focus.ts +143 -0
  54. package/lib/routes/pconline/namespace.ts +10 -0
  55. package/lib/routes/people/index.ts +6 -2
  56. package/lib/routes/pixivision/index.ts +84 -0
  57. package/lib/routes/pixivision/namespace.ts +6 -0
  58. package/lib/routes/pixivision/utils.ts +86 -0
  59. package/lib/routes/pku/bbs/hot.ts +1 -1
  60. package/lib/routes/pornhub/category.ts +3 -2
  61. package/lib/routes/pornhub/model.ts +4 -3
  62. package/lib/routes/pornhub/pornstar.ts +4 -3
  63. package/lib/routes/pornhub/search.ts +3 -2
  64. package/lib/routes/qiche365/namespace.ts +5 -0
  65. package/lib/routes/qiche365/recall.ts +53 -0
  66. package/lib/routes/sdu/{cs.ts → cs/index.ts} +46 -12
  67. package/lib/routes/sdu/namespace.ts +2 -2
  68. package/lib/routes/soundon/namespace.ts +6 -0
  69. package/lib/routes/soundon/podcast.ts +80 -0
  70. package/lib/routes/soundon/types.ts +67 -0
  71. package/lib/routes/swjtu/scai/bks.ts +80 -0
  72. package/lib/routes/telegram/blog.ts +3 -2
  73. package/lib/routes/telegram/stickerpack.ts +3 -2
  74. package/lib/routes/tencent/news/author.ts +2 -1
  75. package/lib/routes/the/index.ts +3 -2
  76. package/lib/routes/theinitium/app.ts +137 -0
  77. package/lib/routes/theinitium/templates/description.art +17 -0
  78. package/lib/routes/threads/index.ts +26 -20
  79. package/lib/routes/tju/cic/index.ts +2 -2
  80. package/lib/routes/tju/news/index.ts +2 -2
  81. package/lib/routes/tju/oaa/index.ts +2 -2
  82. package/lib/routes/twitch/live.ts +3 -2
  83. package/lib/routes/twitch/video.ts +3 -2
  84. package/lib/routes/twitter/api/mobile-api/login.ts +1 -1
  85. package/lib/routes/twitter/api/web-api/constants.ts +15 -14
  86. package/lib/routes/twitter/api/web-api/login.ts +7 -5
  87. package/lib/routes/twitter/api/web-api/utils.ts +1 -2
  88. package/lib/routes/twitter/list.ts +5 -2
  89. package/lib/routes/twitter/tweet.ts +1 -0
  90. package/lib/routes/weibo/namespace.ts +1 -0
  91. package/lib/routes/weibo/oasis/user.ts +1 -1
  92. package/lib/routes/weibo/super-index.ts +23 -11
  93. package/lib/routes/weibo/user.ts +12 -1
  94. package/lib/routes/whu/cs.ts +11 -3
  95. package/lib/routes/whu/gs/index.ts +2 -1
  96. package/lib/routes/whu/news.ts +27 -2
  97. package/lib/routes/withgoogle/explorables.ts +54 -0
  98. package/lib/routes/withgoogle/namespace.ts +6 -0
  99. package/lib/routes/zaobao/util.ts +1 -1
  100. package/lib/routes/zhihu/zhuanlan.ts +8 -7
  101. package/lib/utils/otel/metric.ts +3 -2
  102. package/lib/views/rss.tsx +7 -0
  103. package/package.json +14 -14
@@ -2,16 +2,36 @@ import { Route } from '@/types';
2
2
  import cache from '@/utils/cache';
3
3
  import got from '@/utils/got';
4
4
  import { load } from 'cheerio';
5
+ import { parseDate } from '@/utils/parse-date';
6
+ import timezone from '@/utils/timezone';
5
7
 
6
8
  export const route: Route = {
7
9
  path: '/ndrc/xwdt/:category{.+}?',
8
- name: 'Unknown',
9
- maintainers: [],
10
+ name: '新闻动态',
11
+ example: '/gov/ndrc/xwdt',
12
+ parameters: { category: '分类,见下表,默认为新闻发布' },
13
+ maintainers: ['nczitzk'],
14
+ categories: ['government'],
10
15
  handler,
16
+ radar: [
17
+ {
18
+ title: '中华人民共和国国家发展和改革委员会 - 新闻动态',
19
+ source: ['ndrc.gov.cn/xwdt/:category*'],
20
+ target: (params) => {
21
+ const category = params.category;
22
+
23
+ return `/gov/ndrc/xwdt/${category ? `/${category.endsWith('/') ? category : `${category}/`}` : '/'}`;
24
+ },
25
+ },
26
+ ],
27
+ description: `| 新闻发布 | 通知通告 | 委领导动态 | 司局动态 | 地方动态 |
28
+ | -------- | -------- | ---------- | -------- | -------- |
29
+ | xwfb | tzgg | wlddt | sjdt | dfdt |`,
11
30
  };
12
31
 
13
32
  async function handler(ctx) {
14
33
  const category = ctx.req.param('category') || 'xwfb';
34
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 25;
15
35
 
16
36
  const rootUrl = 'https://www.ndrc.gov.cn';
17
37
  const currentUrl = category.includes('dt') ? `${rootUrl}/xwdt/dt/${category}` : `${rootUrl}/xwdt/${category}`;
@@ -22,8 +42,9 @@ async function handler(ctx) {
22
42
 
23
43
  const $ = load(response.data);
24
44
  const list = $('.u-list li a')
25
- .slice(0, 10)
26
- .map((_, item) => {
45
+ .slice(0, limit)
46
+ .toArray()
47
+ .map((item) => {
27
48
  item = $(item);
28
49
  let link = item.attr('href');
29
50
  if (link.indexOf('../../..') === 0) {
@@ -35,8 +56,7 @@ async function handler(ctx) {
35
56
  title: item.text(),
36
57
  link,
37
58
  };
38
- })
39
- .get();
59
+ });
40
60
 
41
61
  const items = await Promise.all(
42
62
  list.map((item) =>
@@ -47,8 +67,8 @@ async function handler(ctx) {
47
67
  });
48
68
  const content = load(detailResponse.data);
49
69
 
50
- item.description = content('.TRS_Editor').html() || content('.article_con').html();
51
- item.pubDate = new Date(content('meta[name="PubDate"]').attr('content') + ' GMT+8').toUTCString();
70
+ item.description = (content('.TRS_Editor').html() || content('.article_con').html() || '') + (content('.attachment').html() || '');
71
+ item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')!), 8);
52
72
 
53
73
  return item;
54
74
  })
@@ -0,0 +1,73 @@
1
+ import { Route } from '@/types';
2
+ import cache from '@/utils/cache';
3
+ import got from '@/utils/got';
4
+ import { load } from 'cheerio';
5
+ import { parseDate } from '@/utils/parse-date';
6
+
7
+ export const route: Route = {
8
+ path: '/ndrc/zfxxgk/iteminfo',
9
+ categories: ['government'],
10
+ example: '/gov/ndrc/zfxxgk/iteminfo',
11
+ parameters: {},
12
+ features: {
13
+ requireConfig: false,
14
+ requirePuppeteer: false,
15
+ antiCrawler: false,
16
+ supportBT: false,
17
+ supportPodcast: false,
18
+ supportScihub: false,
19
+ },
20
+ name: '国家发展改革委 - 政府信息公开',
21
+ maintainers: ['howfool'],
22
+ handler,
23
+ url: 'zfxxgk.ndrc.gov.cn/web/dirlist.jsp',
24
+ };
25
+
26
+ async function handler() {
27
+ const homeUrl = 'https://zfxxgk.ndrc.gov.cn/web/dirlist.jsp';
28
+ const rootUrl = 'https://zfxxgk.ndrc.gov.cn/web/';
29
+
30
+ const response = await got({
31
+ method: 'get',
32
+ url: homeUrl,
33
+ });
34
+
35
+ const $ = load(response.data);
36
+
37
+ let items = $('div.zwgk-right .zwxxkg-result tr')
38
+ .toArray()
39
+ .slice(1)
40
+ .map((item) => {
41
+ item = $(item);
42
+
43
+ return {
44
+ title: item.find('a').text().replace(/^\s*/, ''),
45
+ link: rootUrl + item.find('a').attr('href'),
46
+ data: item.find('td:last').text(),
47
+ };
48
+ });
49
+
50
+ items = await Promise.all(
51
+ items.map((item) =>
52
+ cache.tryGet(item.link, async () => {
53
+ const detailResponse = await got({
54
+ method: 'get',
55
+ url: item.link,
56
+ });
57
+
58
+ const content = load(detailResponse.data);
59
+ content('[class$="top"]').remove();
60
+ item.description = content('.zwgkbg').html();
61
+ item.pubDate = parseDate(item.data);
62
+
63
+ return item;
64
+ })
65
+ )
66
+ );
67
+
68
+ return {
69
+ title: '国家发展改革委 - 政府信息公开',
70
+ link: homeUrl,
71
+ item: items,
72
+ };
73
+ }
@@ -1,9 +1,10 @@
1
- import { Route } from '@/types';
1
+ import { Route, ViewType } from '@/types';
2
2
  import { ProcessFeed } from './utils';
3
3
 
4
4
  export const route: Route = {
5
5
  path: '/items/all/:order?',
6
- categories: ['anime'],
6
+ categories: ['anime', 'popular'],
7
+ view: ViewType.Pictures,
7
8
  example: '/hpoi/items/all',
8
9
  parameters: { order: '排序, 见下表,默认为 add' },
9
10
  features: {
@@ -1,9 +1,10 @@
1
- import { Route } from '@/types';
1
+ import { Route, ViewType } from '@/types';
2
2
  import { ProcessFeed } from './utils';
3
3
 
4
4
  export const route: Route = {
5
5
  path: '/items/character/:id/:order?',
6
- categories: ['anime'],
6
+ categories: ['anime', 'popular'],
7
+ view: ViewType.Pictures,
7
8
  example: '/hpoi/items/character/1035374',
8
9
  parameters: { id: '角色 ID', order: '排序, 见下表,默认为 add' },
9
10
  features: {
@@ -1,9 +1,10 @@
1
- import { Route } from '@/types';
1
+ import { Route, ViewType } from '@/types';
2
2
  import { ProcessFeed } from './utils';
3
3
 
4
4
  export const route: Route = {
5
5
  path: '/items/work/:id/:order?',
6
- categories: ['anime'],
6
+ categories: ['anime', 'popular'],
7
+ view: ViewType.Pictures,
7
8
  example: '/hpoi/items/work/4117491',
8
9
  parameters: { id: '作品 ID', order: '排序, 见下表,默认为 add' },
9
10
  features: {
@@ -64,6 +64,7 @@ async function handler(ctx) {
64
64
  const chapterUpdatedTime = item.find('td').last().text().trim();
65
65
 
66
66
  const isVip = item.find('span[itemprop="headline"] font').last().text() === '[VIP]';
67
+ const isLock = item.find('td').eq(1).last().text().trim() === '[锁]';
67
68
 
68
69
  return {
69
70
  title: `${chapterName} ${chapterIntro}`,
@@ -82,6 +83,7 @@ async function handler(ctx) {
82
83
  guid: `jjwxc-${id}#${chapterId}`,
83
84
  pubDate: timezone(parseDate(chapterUpdatedTime), +8),
84
85
  isVip,
86
+ isLock,
85
87
  };
86
88
  });
87
89
 
@@ -89,25 +91,27 @@ async function handler(ctx) {
89
91
 
90
92
  items = await Promise.all(
91
93
  items.slice(0, limit).map((item) =>
92
- cache.tryGet(item.link, async () => {
93
- if (!item.isVip) {
94
- const { data: detailResponse } = await got(item.link, {
95
- responseType: 'buffer',
96
- });
94
+ item.isLock
95
+ ? Promise.resolve(item)
96
+ : cache.tryGet(item.link, async () => {
97
+ if (!item.isVip) {
98
+ const { data: detailResponse } = await got(item.link, {
99
+ responseType: 'buffer',
100
+ });
97
101
 
98
- const content = load(iconv.decode(detailResponse, 'gbk'));
102
+ const content = load(iconv.decode(detailResponse, 'gbk'));
99
103
 
100
- content('span.favorite_novel').parent().remove();
104
+ content('span.favorite_novel').parent().remove();
101
105
 
102
- item.description += art(path.join(__dirname, 'templates/book.art'), {
103
- description: content('div.novelbody').html(),
104
- });
105
- }
106
+ item.description += art(path.join(__dirname, 'templates/book.art'), {
107
+ description: content('div.novelbody').html(),
108
+ });
109
+ }
106
110
 
107
- delete item.isVip;
111
+ delete item.isVip;
108
112
 
109
- return item;
110
- })
113
+ return item;
114
+ })
111
115
  )
112
116
  );
113
117
 
@@ -0,0 +1,87 @@
1
+ import { Route } from '@/types';
2
+ import got from '@/utils/got';
3
+ import cache from '@/utils/cache';
4
+ import { config } from '@/config';
5
+ import { parseDate } from '@/utils/parse-date';
6
+
7
+ export const route: Route = {
8
+ path: '/collection/:collectionID',
9
+ categories: ['social-media'],
10
+ example: '/lofter/collection/552041',
11
+ parameters: { collectionID: 'Lofter collection ID, can be found in the share URL' },
12
+ features: {
13
+ requireConfig: false,
14
+ requirePuppeteer: false,
15
+ antiCrawler: false,
16
+ supportBT: false,
17
+ supportPodcast: false,
18
+ supportScihub: false,
19
+ },
20
+ name: 'Collection',
21
+ maintainers: ['SrakhiuMeow'],
22
+ handler,
23
+ };
24
+
25
+ async function fetchCollection(collectionID, limit, offset = 0) {
26
+ const response = await got({
27
+ method: 'post',
28
+ url: 'https://api.lofter.com/v1.1/postCollection.api?product=lofter-android-7.6.12',
29
+ body: new URLSearchParams({
30
+ collectionid: collectionID,
31
+ limit: limit.toString(),
32
+ method: 'getCollectionDetail',
33
+ offset: offset.toString(),
34
+ order: '0',
35
+ }),
36
+ });
37
+
38
+ if (!response.data.response) {
39
+ throw new Error('Collection Not Found');
40
+ }
41
+
42
+ const data = response.data.response;
43
+
44
+ return {
45
+ title: data.collection.name || 'Lofter Collection',
46
+ link: data.blogInfo.homePageUrl || 'https://www.lofter.com/',
47
+ description: data.collection.description || 'No description provided.',
48
+ items: data.items,
49
+ } as object;
50
+ }
51
+
52
+ async function handler(ctx) {
53
+ const collectionID = ctx.req.param('collectionID');
54
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : '50';
55
+
56
+ const response = await cache.tryGet(collectionID, () => fetchCollection(collectionID, Number(limit)), config.cache.routeExpire, false);
57
+
58
+ const { title, link, description, items } = response;
59
+
60
+ const itemsArray = items.map((item) => ({
61
+ title: item.post.title || item.post.noticeLinkTitle,
62
+ link: item.post.blogPageUrl,
63
+ description:
64
+ JSON.parse(item.post.photoLinks || `[]`)
65
+ .map((photo) => {
66
+ if (photo.raw?.match(/\/\/nos\.netease\.com\//)) {
67
+ photo.raw = `https://${photo.raw.match(/(imglf\d)/)[0]}.lf127.net${photo.raw.match(/\/\/nos\.netease\.com\/imglf\d(.*)/)[1]}`;
68
+ }
69
+ return `<img src='${photo.raw || photo.orign}'>`;
70
+ })
71
+ .join('') +
72
+ JSON.parse(item.post.embed ? `[${item.post.embed}]` : `[]`)
73
+ .map((video) => `<video src='${video.originUrl}' poster='${video.video_img_url}' controls='controls'></video>`)
74
+ .join('') +
75
+ item.post.content,
76
+ pubDate: parseDate(item.post.publishTime),
77
+ author: item.post.blogInfo.blogNickName,
78
+ category: item.post.tag.split(','),
79
+ }));
80
+
81
+ return {
82
+ title,
83
+ link,
84
+ item: itemsArray,
85
+ description,
86
+ };
87
+ }
@@ -0,0 +1,179 @@
1
+ import { Route } from '@/types';
2
+ import cache from '@/utils/cache';
3
+ import got from '@/utils/got';
4
+ import parser from '@/utils/rss-parser';
5
+ import { config } from '@/config';
6
+ import { FetchError } from 'ofetch';
7
+
8
+ export const route: Route = {
9
+ path: '/:lang/:category?',
10
+ categories: ['new-media'],
11
+ example: '/malaysiakini/en',
12
+ parameters: {
13
+ lang: 'Language, see below',
14
+ category: 'Category, see below, news by default',
15
+ },
16
+ features: {
17
+ requirePuppeteer: false,
18
+ antiCrawler: false,
19
+ supportBT: false,
20
+ supportPodcast: false,
21
+ supportScihub: false,
22
+ requireConfig: [
23
+ {
24
+ name: 'MALAYSIAKINI_EMAIL',
25
+ optional: true,
26
+ description: 'Malaysiakini Email or Username',
27
+ },
28
+ {
29
+ name: 'MALAYSIAKINI_PASSWORD',
30
+ optional: true,
31
+ description: 'Malaysiakini Password',
32
+ },
33
+ {
34
+ name: 'MALAYSIAKINI_REFRESHTOKEN',
35
+ optional: true,
36
+ description: 'To obtain the refresh token, log into Malaysiakini and look for the cookie `nl____refreshToken` within document.cookie in the browser console. The token is the value of the cookie.',
37
+ },
38
+ ],
39
+ },
40
+ name: 'News',
41
+ maintainers: ['quiniapiezoelectricity'],
42
+ handler,
43
+ description: `
44
+ | Language | English | Bahasa Malaysia | 华文 |
45
+ | -------- | ------ | ------- | ------ |
46
+ | \`:lang\` | \`en\` | \`my\` | \`zh\` |
47
+
48
+ | Category | \`:category\` |
49
+ | ---------------------- | ------------- |
50
+ | News | \`news\` |
51
+ | Columns | \`columns\` |
52
+ | From Our Readers | \`letters\` |`,
53
+ radar: [
54
+ {
55
+ source: ['malaysiakini.com/'],
56
+ target: '/en',
57
+ },
58
+ {
59
+ source: ['malaysiakini.com/:lang'],
60
+ target: '/:lang',
61
+ },
62
+ {
63
+ source: ['www.malaysiakini.com/:lang/latest/:category'],
64
+ target: '/:lang/:category',
65
+ },
66
+ ],
67
+ };
68
+
69
+ async function handler(ctx) {
70
+ const lang = ctx.req.param('lang');
71
+ const category = ctx.req.param('category') ?? 'news';
72
+ const apiKey = 'UFXL7F1EL53S8DZ5SGJUMG5IIFVRY4WI'; // Assuming the apiKey is static
73
+
74
+ const key = {
75
+ email: config.malaysiakini.email,
76
+ password: config.malaysiakini.password,
77
+ apiKey,
78
+ };
79
+ const body = JSON.stringify(key);
80
+
81
+ let cookie;
82
+
83
+ const cacheIn = await cache.get('malaysiakini:cookie');
84
+ if (cacheIn) {
85
+ cookie = cacheIn;
86
+ }
87
+
88
+ if (cookie === undefined && config.malaysiakini.email && config.malaysiakini.password) {
89
+ const login = await got.post('https://membership.malaysiakini.com/api/v1/auth/local', {
90
+ headers: {
91
+ 'Content-Type': 'application/json',
92
+ Accept: '*/*',
93
+ Connection: 'keep-alive',
94
+ },
95
+ body,
96
+ });
97
+ if (login.data.accessToken && login.data.refreshToken) {
98
+ cookie = `nl____accessToken=${login.data.accessToken}; nl____refreshToken=${login.data.refreshToken};`;
99
+ // Refresh token should be sufficient for authenticating for full text, but access token is included for good measure.
100
+ cache.set('malaysiakini:cookie', cookie);
101
+ }
102
+ }
103
+
104
+ if (cookie === undefined && config.malaysiakini.refreshToken) {
105
+ cookie = `nl____refreshToken=${config.malaysiakini.refreshToken};`;
106
+ cache.set('malaysiakini:cookie', cookie);
107
+ }
108
+
109
+ const link = `https://www.malaysiakini.com/rss/${lang}/${category}.rss`;
110
+ const feed = await parser.parseURL(link);
111
+
112
+ if (cookie) {
113
+ // Testing the cookie with the first item of the feed
114
+ try {
115
+ await got({
116
+ method: 'get',
117
+ url: `https://www.malaysiakini.com/api/full_content/${feed.items[0].guid}`,
118
+ headers: {
119
+ Cookie: cookie,
120
+ },
121
+ });
122
+ } catch (error) {
123
+ if (error instanceof FetchError && error.statusCode === 401) {
124
+ await cache.set('malaysiakini:cookie', '');
125
+ }
126
+ throw error;
127
+ }
128
+ }
129
+
130
+ const items = await Promise.all(
131
+ feed.items.map((item) =>
132
+ cache.tryGet(item.link, async () => {
133
+ const response = await got(`https://www.malaysiakini.com/api/content/${item.guid}`);
134
+ if (response.data.stories.content) {
135
+ item.description = response.data.stories.content;
136
+ } else {
137
+ item.description = response.data.stories.teaser;
138
+ if (cookie) {
139
+ let fullResponse;
140
+ try {
141
+ fullResponse = await got({
142
+ method: 'get',
143
+ url: `https://www.malaysiakini.com/api/full_content/${item.guid}`,
144
+ headers: {
145
+ Cookie: cookie,
146
+ },
147
+ });
148
+ } finally {
149
+ if (fullResponse) {
150
+ item.description = fullResponse.data.content;
151
+ }
152
+ }
153
+ }
154
+ }
155
+ if (response.data.stories.image_feat) {
156
+ const cover = response.data.stories.image_feat;
157
+ if (cover.length > 0) {
158
+ item.description = `<img src=${cover[0]}>` + item.description;
159
+ }
160
+ }
161
+ if (response.data.stories.author) {
162
+ item.author = response.data.stories.author;
163
+ }
164
+ if (response.data.stories.tags) {
165
+ item.category = response.data.stories.tags;
166
+ }
167
+ return item;
168
+ })
169
+ )
170
+ );
171
+
172
+ return {
173
+ title: feed.title,
174
+ link: feed.link,
175
+ description: feed.description,
176
+ language: lang,
177
+ item: items,
178
+ };
179
+ }
@@ -0,0 +1,11 @@
1
+ import type { Namespace } from '@/types';
2
+
3
+ export const namespace: Namespace = {
4
+ name: 'Malaysiakini 当今大马',
5
+ url: 'malaysiakini.com',
6
+ description: `Provides an easy-to-use RSS feed for Malaysiakini.com with teaser/full-text fetching.
7
+ :::warning
8
+ A subscription is required for fetching full articles.
9
+ Please refer to the deployment config for more information.
10
+ :::`,
11
+ };
@@ -1,10 +1,11 @@
1
- import { Route } from '@/types';
1
+ import { Route, ViewType } from '@/types';
2
2
  import utils from './utils';
3
3
 
4
4
  export const route: Route = {
5
5
  path: '/acct/:acct/statuses/:only_media?',
6
- categories: ['social-media'],
7
- example: '/mastodon/acct/CatWhitney@mastodon.social/statuses',
6
+ categories: ['social-media', 'popular'],
7
+ view: ViewType.SocialMedia,
8
+ example: '/mastodon/acct/Mastodon@mastodon.social/statuses',
8
9
  parameters: { acct: 'Webfinger account URI, like `user@host`', only_media: 'whether only display media content, default to false, any value to true' },
9
10
  features: {
10
11
  requireConfig: false,
@@ -1,4 +1,4 @@
1
- import { Route } from '@/types';
1
+ import { Route, ViewType } from '@/types';
2
2
  import got from '@/utils/got';
3
3
  import utils from './utils';
4
4
  import { config } from '@/config';
@@ -6,7 +6,8 @@ import ConfigNotFoundError from '@/errors/types/config-not-found';
6
6
 
7
7
  export const route: Route = {
8
8
  path: '/timeline/:site/:only_media?',
9
- categories: ['social-media'],
9
+ categories: ['social-media', 'popular'],
10
+ view: ViewType.SocialMedia,
10
11
  example: '/mastodon/timeline/pawoo.net/true',
11
12
  parameters: { site: 'instance address, only domain, no `http://` or `https://` protocol header', only_media: 'whether only display media content, default to false, any value to true' },
12
13
  features: {
@@ -1,4 +1,4 @@
1
- import { Route } from '@/types';
1
+ import { Route, ViewType } from '@/types';
2
2
  import got from '@/utils/got';
3
3
  import utils from './utils';
4
4
  import { config } from '@/config';
@@ -6,7 +6,8 @@ import ConfigNotFoundError from '@/errors/types/config-not-found';
6
6
 
7
7
  export const route: Route = {
8
8
  path: '/remote/:site/:only_media?',
9
- categories: ['social-media'],
9
+ categories: ['social-media', 'popular'],
10
+ view: ViewType.SocialMedia,
10
11
  example: '/mastodon/remote/pawoo.net/true',
11
12
  parameters: { site: 'instance address, only domain, no `http://` or `https://` protocol header', only_media: 'whether only display media content, default to false, any value to true' },
12
13
  features: {