rsshub 1.0.0-master.e6d4e1e → 1.0.0-master.e6d53dc

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 (241) hide show
  1. package/lib/api/radar/rules/all.ts +3 -6
  2. package/lib/api/radar/rules/one.ts +3 -6
  3. package/lib/config.ts +12 -22
  4. package/lib/errors/index.tsx +1 -1
  5. package/lib/index.ts +1 -1
  6. package/lib/middleware/anti-hotlink.test.ts +191 -6
  7. package/lib/middleware/anti-hotlink.ts +28 -0
  8. package/lib/middleware/parameter.test.ts +22 -5
  9. package/lib/middleware/parameter.ts +47 -17
  10. package/lib/registry.test.ts +8 -0
  11. package/lib/registry.ts +2 -0
  12. package/lib/router.js +0 -3
  13. package/lib/routes/141jav/index.ts +25 -21
  14. package/lib/routes/141ppv/index.ts +24 -20
  15. package/lib/routes/51read/article.ts +82 -0
  16. package/lib/routes/51read/namespace.ts +6 -0
  17. package/lib/routes/5eplay/utils.ts +5 -3
  18. package/lib/routes/agri/index.ts +307 -0
  19. package/lib/routes/agri/namespace.ts +8 -0
  20. package/lib/routes/agri/templates/description.art +21 -0
  21. package/lib/routes/aljazeera/index.ts +2 -2
  22. package/lib/routes/apnews/sitemap.ts +98 -0
  23. package/lib/routes/apnews/utils.ts +7 -5
  24. package/lib/routes/autocentre/index.ts +29 -0
  25. package/lib/routes/autocentre/namespace.ts +7 -0
  26. package/lib/routes/bilibili/api-interface.d.ts +1 -0
  27. package/lib/routes/bilibili/cache.ts +3 -1
  28. package/lib/routes/bilibili/dynamic.ts +7 -9
  29. package/lib/routes/binance/announcement.ts +168 -0
  30. package/lib/routes/binance/types.ts +26 -0
  31. package/lib/routes/bing/daily-wallpaper.ts +1 -1
  32. package/lib/routes/bjnews/cat.ts +43 -0
  33. package/lib/routes/bjnews/column.ts +43 -0
  34. package/lib/routes/bjnews/namespace.ts +6 -0
  35. package/lib/routes/bjnews/utils.ts +19 -0
  36. package/lib/routes/bjx/fd.ts +35 -26
  37. package/lib/routes/buaa/jiaowu.ts +1 -1
  38. package/lib/routes/buaa/lib/space/newbook.ts +171 -0
  39. package/lib/routes/buaa/lib/space/templates/newbook.art +44 -0
  40. package/lib/routes/cccfna/index.ts +2 -2
  41. package/lib/routes/cctv/category.ts +16 -12
  42. package/lib/routes/cctv/xwlb.ts +32 -10
  43. package/lib/routes/cdu/jwgg.ts +79 -0
  44. package/lib/routes/cdu/namespace.ts +6 -0
  45. package/lib/routes/cffex/announcement.ts +73 -0
  46. package/lib/routes/cffex/namespace.ts +6 -0
  47. package/lib/routes/chlinlearn/daily-blog.ts +55 -0
  48. package/lib/routes/chlinlearn/namespcae.ts +6 -0
  49. package/lib/routes/copymanga/comic.ts +3 -1
  50. package/lib/routes/devolverdigital/blog.ts +59 -42
  51. package/lib/routes/digitalcameraworld/news.ts +1 -1
  52. package/lib/routes/discord/channel.ts +10 -10
  53. package/lib/routes/discord/discord-api.ts +27 -32
  54. package/lib/routes/discord/templates/message.art +15 -0
  55. package/lib/routes/discourse/notifications.ts +2 -1
  56. package/lib/routes/dongqiudi/result.ts +1 -1
  57. package/lib/routes/eastmoney/report/index.ts +63 -15
  58. package/lib/routes/eastmoney/templates/stock_description.art +36 -0
  59. package/lib/routes/eastmoney/utils.ts +35 -0
  60. package/lib/routes/fediverse/timeline.ts +35 -18
  61. package/lib/routes/flashcat/blog.ts +61 -0
  62. package/lib/routes/flashcat/namespace.ts +6 -0
  63. package/lib/routes/ftm/index.ts +60 -0
  64. package/lib/routes/ftm/namespace.ts +6 -0
  65. package/lib/routes/galxe/index.ts +94 -0
  66. package/lib/routes/galxe/namespace.ts +9 -0
  67. package/lib/routes/gamersky/ent.ts +57 -0
  68. package/lib/routes/gamersky/namespace.ts +10 -0
  69. package/lib/routes/gamersky/news.ts +91 -0
  70. package/lib/routes/gamersky/review.ts +80 -0
  71. package/lib/routes/gamersky/utils.ts +94 -0
  72. package/lib/routes/gdut/oa-news.ts +12 -17
  73. package/lib/routes/gisreportsonline/index.ts +60 -0
  74. package/lib/routes/gisreportsonline/namespace.ts +6 -0
  75. package/lib/routes/github/activity.ts +4 -3
  76. package/lib/routes/github/search.ts +20 -18
  77. package/lib/routes/google/research.ts +45 -0
  78. package/lib/routes/gov/cbirc/index.ts +371 -0
  79. package/lib/routes/gov/chongqing/sydwgkzp.ts +4 -4
  80. package/lib/routes/gov/lswz/index.ts +289 -0
  81. package/lib/routes/gov/zj/ningbogzw-notice.ts +50 -0
  82. package/lib/routes/gov/zj/ningborsjnotice.ts +50 -0
  83. package/lib/routes/gq/news.ts +1 -1
  84. package/lib/routes/gs/developer/blog.ts +58 -0
  85. package/lib/routes/gs/namespace.ts +9 -0
  86. package/lib/routes/healthz.ts +8 -0
  87. package/lib/routes/hket/index.ts +80 -76
  88. package/lib/routes/hottoys/index.ts +63 -0
  89. package/lib/routes/hottoys/namespace.ts +6 -0
  90. package/lib/routes/hust/gs.ts +281 -0
  91. package/lib/routes/hust/namespace.ts +1 -1
  92. package/lib/routes/imhcg/blog.ts +47 -0
  93. package/lib/routes/imhcg/namespace.ts +7 -0
  94. package/lib/routes/imop/namespace.ts +10 -0
  95. package/lib/routes/imop/tianshu.ts +53 -0
  96. package/lib/routes/infzm/hot.ts +39 -0
  97. package/lib/routes/infzm/index.ts +3 -30
  98. package/lib/routes/infzm/utils.ts +34 -0
  99. package/lib/routes/inspirehep/author.ts +46 -0
  100. package/lib/routes/inspirehep/literature.ts +42 -0
  101. package/lib/routes/inspirehep/namespace.ts +7 -0
  102. package/lib/routes/inspirehep/types.ts +210 -0
  103. package/lib/routes/inspirehep/utils.ts +15 -0
  104. package/lib/routes/iwara/subscriptions.ts +1 -1
  105. package/lib/routes/javdb/actors.ts +6 -2
  106. package/lib/routes/joins/chinese.ts +218 -0
  107. package/lib/routes/joins/namespace.ts +8 -0
  108. package/lib/routes/joins/templates/description.art +17 -0
  109. package/lib/routes/juejin/dynamic.ts +114 -0
  110. package/lib/routes/kaopu/news.ts +3 -3
  111. package/lib/routes/kemono/index.ts +21 -0
  112. package/lib/routes/keylol/index.ts +56 -11
  113. package/lib/routes/kurogames/namespace.ts +7 -0
  114. package/lib/routes/kurogames/wutheringwaves/news.ts +59 -0
  115. package/lib/routes/link3/events.ts +86 -0
  116. package/lib/routes/link3/namespace.ts +6 -0
  117. package/lib/routes/link3/profile.ts +143 -0
  118. package/lib/routes/linkedin/cn/renderer.ts +1 -1
  119. package/lib/routes/lmu/jobs.ts +96 -0
  120. package/lib/routes/lmu/namespace.ts +17 -0
  121. package/lib/routes/lmu/templates/jobPosting.art +11 -0
  122. package/lib/routes/mcmod/index.ts +105 -0
  123. package/lib/routes/mcmod/namespace.ts +6 -0
  124. package/lib/routes/mcmod/templates/mod.art +13 -0
  125. package/lib/routes/misskey/user-timeline.ts +42 -0
  126. package/lib/routes/misskey/utils.ts +41 -1
  127. package/lib/routes/nationalgeographic/latest-stories.ts +1 -1
  128. package/lib/routes/nationalgeographic/templates/stories.art +1 -1
  129. package/lib/routes/newyorker/news.ts +24 -17
  130. package/lib/routes/oschina/news.ts +2 -0
  131. package/lib/routes/people/index.ts +4 -2
  132. package/lib/routes/picnob/user.ts +11 -3
  133. package/lib/routes/pixiv/search.ts +20 -1
  134. package/lib/routes/pixiv/utils.ts +3 -3
  135. package/lib/routes/psyche/topic.ts +1 -1
  136. package/lib/routes/psyche/type.ts +1 -1
  137. package/lib/routes/psyche/utils.ts +1 -1
  138. package/lib/routes/questn/community.ts +76 -0
  139. package/lib/routes/questn/events.ts +101 -0
  140. package/lib/routes/questn/namespace.ts +6 -0
  141. package/lib/routes/questn/util.ts +16 -0
  142. package/lib/routes/rebase/geekdaily.ts +35 -0
  143. package/lib/routes/rebase/namespace.ts +6 -0
  144. package/lib/routes/rss3/index.ts +22 -13
  145. package/lib/routes/rss3/interfaces/metadata.ts +67 -0
  146. package/lib/routes/rsshub/routes.ts +18 -12
  147. package/lib/routes/samd/news.ts +1 -1
  148. package/lib/routes/sara/index.ts +1 -1
  149. package/lib/routes/scut/gzic/media.ts +71 -0
  150. package/lib/routes/scut/gzic/news.ts +65 -0
  151. package/lib/routes/scut/gzic/notice.ts +88 -0
  152. package/lib/routes/shiep/config.ts +4 -10
  153. package/lib/routes/shiep/index.ts +9 -9
  154. package/lib/routes/showstart/artist.ts +5 -4
  155. package/lib/routes/showstart/brand.ts +5 -4
  156. package/lib/routes/showstart/event.ts +8 -7
  157. package/lib/routes/showstart/search.ts +43 -9
  158. package/lib/routes/showstart/service.ts +81 -53
  159. package/lib/routes/showstart/site.ts +41 -0
  160. package/lib/routes/showstart/utils.ts +9 -8
  161. package/lib/routes/sis001/author.ts +52 -0
  162. package/lib/routes/sis001/common.ts +38 -0
  163. package/lib/routes/sis001/forum.ts +2 -29
  164. package/lib/routes/sjtu/jwc.ts +4 -1
  165. package/lib/routes/sjtu/namespace.ts +1 -1
  166. package/lib/routes/sjtu/seiee/index.ts +97 -0
  167. package/lib/routes/smzdm/product.ts +86 -0
  168. package/lib/routes/spotify/show.ts +1 -1
  169. package/lib/routes/springer/journal.ts +10 -12
  170. package/lib/routes/sse/sselawsrules.ts +370 -0
  171. package/lib/routes/sspai/author.ts +1 -1
  172. package/lib/routes/sspai/column.ts +1 -1
  173. package/lib/routes/sspai/index.ts +1 -1
  174. package/lib/routes/sspai/matrix.ts +1 -1
  175. package/lib/routes/sspai/series-update.ts +1 -1
  176. package/lib/routes/sspai/tag.ts +1 -1
  177. package/lib/routes/sspai/topic.ts +1 -1
  178. package/lib/routes/sustainabilitymag/articles.ts +2 -0
  179. package/lib/routes/szse/rule.ts +315 -42
  180. package/lib/routes/t66y/index.ts +29 -7
  181. package/lib/routes/taoguba/blog.ts +1 -1
  182. package/lib/routes/taoguba/index.ts +1 -1
  183. package/lib/routes/techcrunch/news.ts +20 -29
  184. package/lib/routes/techcrunch/templates/description.art +7 -0
  185. package/lib/routes/telegram/channel.ts +34 -1
  186. package/lib/routes/test/index.ts +50 -43
  187. package/lib/routes/the/index.ts +210 -0
  188. package/lib/routes/the/namespace.ts +8 -0
  189. package/lib/routes/the/templates/description.art +27 -0
  190. package/lib/routes/the/util.ts +307 -0
  191. package/lib/routes/theblockbeats/index.ts +10 -5
  192. package/lib/routes/towardsdatascience/latest.ts +67 -0
  193. package/lib/routes/towardsdatascience/namespace.ts +6 -0
  194. package/lib/routes/tvb/news.ts +1 -0
  195. package/lib/routes/twitter/api/index.ts +2 -0
  196. package/lib/routes/twitter/api/web-api/api.ts +18 -0
  197. package/lib/routes/twitter/api/web-api/constants.ts +2 -0
  198. package/lib/routes/twitter/api/web-api/login.ts +66 -0
  199. package/lib/routes/twitter/api/web-api/utils.ts +53 -27
  200. package/lib/routes/twitter/home-latest.ts +60 -0
  201. package/lib/routes/twitter/home.ts +1 -1
  202. package/lib/routes/twitter/user.ts +1 -1
  203. package/lib/routes/twitter/utils.ts +4 -1
  204. package/lib/routes/uber/blog.ts +1 -1
  205. package/lib/routes/ustc/scms.ts +97 -0
  206. package/lib/routes/v2ex/xna.ts +55 -0
  207. package/lib/routes/wchscu/namespace.ts +6 -0
  208. package/lib/routes/wchscu/recruit.ts +73 -0
  209. package/lib/routes/xiaohongshu/notes.ts +10 -2
  210. package/lib/routes/xiaohongshu/user.ts +23 -2
  211. package/lib/routes/xidian/cs.ts +143 -0
  212. package/lib/routes/xidian/gr.ts +289 -0
  213. package/lib/routes/xidian/jwc.ts +1 -0
  214. package/lib/routes/xidian/namespace.ts +1 -1
  215. package/lib/routes/yahoo/news/index.ts +1 -0
  216. package/lib/routes/yahoo/news/listid.ts +67 -0
  217. package/lib/routes/yahoo/news/utils.ts +8 -2
  218. package/lib/routes/yicai/carousel.ts +48 -0
  219. package/lib/routes/yicai/utils.ts +23 -17
  220. package/lib/routes/youtube/subscriptions.ts +1 -0
  221. package/lib/routes/yystv/docs.ts +28 -19
  222. package/lib/routes/zhihu/answers.ts +5 -1
  223. package/lib/routes/zhihu/execlib/x-zse-96-v3.ts +2 -0
  224. package/lib/routes/zhihu/namespace.ts +3 -0
  225. package/lib/routes/zhihu/utils.ts +15 -2
  226. package/lib/routes/zsxq/types.ts +9 -0
  227. package/lib/routes/zsxq/utils.ts +4 -3
  228. package/lib/setup.test.ts +1 -1
  229. package/lib/types.ts +6 -0
  230. package/lib/utils/cache/index.ts +8 -0
  231. package/lib/utils/camelcase-keys.spec.ts +127 -0
  232. package/lib/utils/camelcase-keys.ts +27 -0
  233. package/lib/utils/common-utils.ts +1 -0
  234. package/lib/views/error.tsx +3 -3
  235. package/lib/views/index.tsx +4 -3
  236. package/lib/views/layout.tsx +1 -1
  237. package/package.json +46 -44
  238. package/lib/routes/sse/lawandrules.ts +0 -68
  239. package/lib/routes-deprecated/bjnews/news.js +0 -44
  240. package/lib/routes-deprecated/gamersky/ent.js +0 -89
  241. package/lib/routes-deprecated/gamersky/news.js +0 -34
@@ -4,37 +4,30 @@ import { config } from '@/config';
4
4
  import got from '@/utils/got';
5
5
  import queryString from 'query-string';
6
6
  import { Cookie, CookieJar } from 'tough-cookie';
7
- import { CookieAgent } from 'http-cookie-agent/undici';
7
+ import { CookieAgent, CookieClient } from 'http-cookie-agent/undici';
8
+ import { ProxyAgent } from 'undici';
8
9
  import cache from '@/utils/cache';
9
10
  import logger from '@/utils/logger';
10
- import { RateLimiterMemory, RateLimiterRedis, RateLimiterQueue } from 'rate-limiter-flexible';
11
11
  import ofetch from '@/utils/ofetch';
12
+ import proxy from '@/utils/proxy';
13
+ import login from './login';
12
14
 
13
15
  const dispatchers = {};
14
16
  let authTokenIndex = 0;
15
17
 
16
- const loginLimiter = cache.clients.redisClient
17
- ? new RateLimiterRedis({
18
- points: 1,
19
- duration: 5,
20
- execEvenly: true,
21
- storeClient: cache.clients.redisClient,
22
- })
23
- : new RateLimiterMemory({
24
- points: 1,
25
- duration: 5,
26
- execEvenly: true,
27
- });
28
-
29
- const loginLimiterQueue = new RateLimiterQueue(loginLimiter);
30
-
31
18
  const token2Cookie = (token) =>
32
19
  cache.tryGet(`twitter:cookie:${token}`, async () => {
33
20
  const jar = new CookieJar();
34
21
  jar.setCookieSync(`auth_token=${token}`, 'https://x.com');
35
22
  try {
23
+ const agent = proxy.proxyUri
24
+ ? new ProxyAgent({
25
+ factory: (origin, opts) => new CookieClient(origin as string, { ...opts, cookies: { jar } }),
26
+ uri: proxy.proxyUri,
27
+ })
28
+ : new CookieAgent({ cookies: { jar } });
36
29
  await got('https://x.com', {
37
- dispatcher: new CookieAgent({ cookies: { jar } }),
30
+ dispatcher: agent,
38
31
  });
39
32
  return JSON.stringify(jar.serializeSync());
40
33
  } catch {
@@ -47,18 +40,37 @@ export const twitterGot = async (url, params) => {
47
40
  if (!config.twitter.authToken) {
48
41
  throw new ConfigNotFoundError('Twitter cookie is not configured');
49
42
  }
50
- await loginLimiterQueue.removeTokens(1);
51
- const token = config.twitter.authToken[authTokenIndex++ % config.twitter.authToken.length];
52
- let cookie = await token2Cookie(token);
43
+ const index = authTokenIndex++ % config.twitter.authToken.length;
44
+ const token = config.twitter.authToken[index];
45
+
46
+ const requestUrl = `${url}?${queryString.stringify(params)}`;
47
+
48
+ let cookie: string | Record<string, any> | null | undefined = await token2Cookie(token);
49
+ if (!cookie) {
50
+ cookie = await login({
51
+ username: config.twitter.username?.[index],
52
+ password: config.twitter.password?.[index],
53
+ authenticationSecret: config.twitter.authenticationSecret?.[index],
54
+ });
55
+ }
53
56
  if (cookie) {
54
57
  logger.debug(`Got twitter cookie for token ${token}`);
55
58
  if (typeof cookie === 'string') {
56
59
  cookie = JSON.parse(cookie);
57
60
  }
58
61
  const jar = CookieJar.deserializeSync(cookie as any);
62
+ const agent = proxy.proxyUri
63
+ ? new ProxyAgent({
64
+ factory: (origin, opts) => new CookieClient(origin as string, { ...opts, cookies: { jar } }),
65
+ uri: proxy.proxyUri,
66
+ })
67
+ : new CookieAgent({ cookies: { jar } });
68
+ if (proxy.proxyUri) {
69
+ logger.debug(`Proxying request: ${requestUrl}`);
70
+ }
59
71
  dispatchers[token] = {
60
72
  jar,
61
- agent: new CookieAgent({ cookies: { jar } }),
73
+ agent,
62
74
  };
63
75
  } else {
64
76
  throw new ConfigNotFoundError(`Twitter cookie for token ${token} is not valid`);
@@ -71,7 +83,8 @@ export const twitterGot = async (url, params) => {
71
83
  .map((c) => [c?.key, c?.value])
72
84
  );
73
85
 
74
- const response = await ofetch.raw(`${url}?${queryString.stringify(params)}`, {
86
+ const response = await ofetch.raw(requestUrl, {
87
+ retry: 0,
75
88
  headers: {
76
89
  authority: 'x.com',
77
90
  accept: '*/*',
@@ -89,15 +102,28 @@ export const twitterGot = async (url, params) => {
89
102
  },
90
103
  dispatcher: dispatchers[token].agent,
91
104
  onResponse: async ({ response }) => {
92
- if (response.status === 403) {
93
- logger.debug(`Delete twitter cookie for token ${token}`);
94
- await cache.set(`twitter:cookie:${token}`, '', config.cache.contentExpire);
105
+ if (response.status === 403 || response.status === 401 || response.status === 429) {
106
+ const newCookie = await login({
107
+ username: config.twitter.username?.[index],
108
+ password: config.twitter.password?.[index],
109
+ authenticationSecret: config.twitter.authenticationSecret?.[index],
110
+ });
111
+ if (newCookie) {
112
+ await cache.set(`twitter:cookie:${token}`, newCookie, config.cache.contentExpire);
113
+ logger.debug(`Reset twitter cookie for token ${token}`);
114
+ } else {
115
+ config.twitter.authToken?.splice(index, 1);
116
+ config.twitter.username?.splice(index, 1);
117
+ config.twitter.password?.splice(index, 1);
118
+ await cache.set(`twitter:cookie:${token}`, '', config.cache.contentExpire);
119
+ logger.debug(`Delete twitter cookie for token ${token}, remaining tokens: ${config.twitter.authToken?.length}`);
120
+ }
95
121
  }
96
122
  },
97
123
  });
98
124
 
99
125
  if (token) {
100
- logger.debug(`Reset twitter cookie for token ${token}`);
126
+ logger.debug(`Update twitter cookie for token ${token}`);
101
127
  await cache.set(`twitter:cookie:${token}`, JSON.stringify(dispatchers[token].jar.serializeSync()), config.cache.contentExpire);
102
128
  }
103
129
 
@@ -0,0 +1,60 @@
1
+ import { Route } from '@/types';
2
+ import utils from './utils';
3
+ import api from './api';
4
+
5
+ export const route: Route = {
6
+ path: '/home_latest/:routeParams?',
7
+ categories: ['social-media'],
8
+ example: '/twitter/home_latest',
9
+ features: {
10
+ requireConfig: [
11
+ {
12
+ name: 'TWITTER_USERNAME',
13
+ description: 'Please see above for details.',
14
+ },
15
+ {
16
+ name: 'TWITTER_PASSWORD',
17
+ description: 'Please see above for details.',
18
+ },
19
+ {
20
+ name: 'TWITTER_AUTH_TOKEN',
21
+ description: 'Please see above for details.',
22
+ },
23
+ ],
24
+ requirePuppeteer: false,
25
+ antiCrawler: false,
26
+ supportBT: false,
27
+ supportPodcast: false,
28
+ supportScihub: false,
29
+ },
30
+ name: 'Home latest timeline',
31
+ maintainers: ['DIYgod', 'CaoMeiYouRen'],
32
+ handler,
33
+ radar: [
34
+ {
35
+ source: ['x.com/home'],
36
+ target: '/home_latest',
37
+ },
38
+ ],
39
+ };
40
+
41
+ async function handler(ctx) {
42
+ // For compatibility
43
+ const { count, include_rts } = utils.parseRouteParams(ctx.req.param('routeParams'));
44
+ const params = count ? { count } : {};
45
+
46
+ await api.init();
47
+ let data = await api.getHomeLatestTimeline('', params);
48
+ if (!include_rts) {
49
+ data = utils.excludeRetweet(data);
50
+ }
51
+
52
+ return {
53
+ title: `Twitter following timeline`,
54
+ link: `https://x.com/home`,
55
+ // description: userInfo?.description,
56
+ item: utils.ProcessFeed(ctx, {
57
+ data,
58
+ }),
59
+ };
60
+ }
@@ -28,7 +28,7 @@ export const route: Route = {
28
28
  supportScihub: false,
29
29
  },
30
30
  name: 'Home timeline',
31
- maintainers: ['DIYgod'],
31
+ maintainers: ['DIYgod', 'CaoMeiYouRen'],
32
32
  handler,
33
33
  radar: [
34
34
  {
@@ -39,7 +39,7 @@ export const route: Route = {
39
39
  supportScihub: false,
40
40
  },
41
41
  name: 'User timeline',
42
- maintainers: ['DIYgod', 'yindaheng98', 'Rongronggg9'],
42
+ maintainers: ['DIYgod', 'yindaheng98', 'Rongronggg9', 'CaoMeiYouRen'],
43
43
  handler,
44
44
  radar: [
45
45
  {
@@ -104,7 +104,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
104
104
  if (!readable) {
105
105
  content += '<br>';
106
106
  }
107
- content += `<video src='${video.url}' ${gifAutoPlayAttr} controls='controls' poster='${getOriginalImg(media.media_url_https)}' ${extraAttrs}></video>`;
107
+ content += `<video width="${media.sizes.large.w}" height="${media.sizes.large.h}" src='${video.url}' ${gifAutoPlayAttr} controls='controls' poster='${getOriginalImg(media.media_url_https)}' ${extraAttrs}></video>`;
108
108
  }
109
109
 
110
110
  return content;
@@ -142,6 +142,9 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
142
142
  content += `height="${heightOfPics}" `;
143
143
  style += `height: ${heightOfPics}px;`;
144
144
  }
145
+ if (widthOfPics <= 0 && heightOfPics <= 0) {
146
+ content += `width="${media.sizes.large.w}" height="${media.sizes.large.h}" `;
147
+ }
145
148
  content += ` style="${style}" ` + `${readable ? 'hspace="4" vspace="8"' : ''} src="${originalImg}">`;
146
149
  if (addLinkForPics) {
147
150
  content += `</a>`;
@@ -21,7 +21,7 @@ export const route: Route = {
21
21
  },
22
22
  radar: [
23
23
  {
24
- source: ['www.uber.com/blog/pittsburgh/engineering'],
24
+ source: ['www.uber.com/:language/blog/engineering', 'www.uber.com/:language/blog'],
25
25
  target: '/blog',
26
26
  },
27
27
  ],
@@ -0,0 +1,97 @@
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
+ import timezone from '@/utils/timezone';
7
+ // import InvalidParameterError from '@/errors/types/invalid-parameter';
8
+
9
+ const map = new Map([
10
+ ['kydt', { title: '科研动态', id: '2404' }],
11
+ ['tzgg', { title: '通知公告', id: '2402' }],
12
+ ['xshd', { title: '学术活动', id: 'xshd' }],
13
+ ['ynxw', { title: '院内新闻', id: '2405' }],
14
+ ]);
15
+
16
+ const host = 'https://scms.ustc.edu.cn';
17
+
18
+ export const route: Route = {
19
+ path: '/scms/:type?',
20
+ categories: ['university'],
21
+ example: '/ustc/scms/tzgg',
22
+ parameters: { type: '分类,见下表,默认为通知公告' },
23
+ features: {
24
+ requireConfig: false,
25
+ requirePuppeteer: false,
26
+ antiCrawler: false,
27
+ supportBT: false,
28
+ supportPodcast: false,
29
+ supportScihub: false,
30
+ },
31
+ radar: [
32
+ {
33
+ source: ['scms.ustc.edu.cn/:id/list.htm'],
34
+ target: '/scms',
35
+ },
36
+ ],
37
+ name: '化学与材料科学学院',
38
+ maintainers: ['boxie123'],
39
+ handler,
40
+ url: 'scms.ustc.edu.cn/',
41
+ description: `| 院内新闻 | 通知公告 | 科研动态 | 学术活动 | 其他 |
42
+ | -------- | -------- | -------- | -------- | -------- |
43
+ | ynxw | tzgg | kydt | xshd | 自定义id |`,
44
+ };
45
+
46
+ async function handler(ctx) {
47
+ const type = ctx.req.param('type') ?? 'tzgg';
48
+ const info = map.get(type);
49
+ // ?? { title: `中国科学技术大学化学与材料科学学院 - ${type}`, id: type };
50
+ // if (!info) {
51
+ // throw new InvalidParameterError('invalid type');
52
+ // }
53
+ const id = info?.id ?? type;
54
+
55
+ const response = await got(`${host}/${id}/list.htm`);
56
+ const $ = load(response.data);
57
+
58
+ const pageTitle = info?.title ?? $('head > title').text();
59
+
60
+ let items = $('#wp_news_w6 > .wp_article_list > .list_item')
61
+ .toArray()
62
+ .map((item) => {
63
+ const elem = $(item);
64
+ const title = elem.find('.Article_Title > a').attr('title').trim();
65
+ let link = elem.find('.Article_Title > a').attr('href');
66
+ link = link.startsWith('/') ? host + link : link;
67
+ // Assume that the articles are published at 12:00 UTC+8
68
+ const pubDate = timezone(parseDate(elem.find('.Article_PublishDate').text(), 'YYYY-MM-DD'), -4);
69
+ return {
70
+ title,
71
+ pubDate,
72
+ link,
73
+ };
74
+ });
75
+
76
+ items = await Promise.all(
77
+ items.map((item) =>
78
+ cache.tryGet(item.link, async () => {
79
+ let desc = '';
80
+ try {
81
+ const response = await got(item.link);
82
+ desc = load(response.data)('div.wp_articlecontent').html();
83
+ item.description = desc;
84
+ } catch {
85
+ // Intranet only contents
86
+ }
87
+ return item;
88
+ })
89
+ )
90
+ );
91
+
92
+ return {
93
+ title: `中国科学技术大学化学与材料科学学院 - ${pageTitle}`,
94
+ link: `${host}/${id}/list.htm`,
95
+ item: items,
96
+ };
97
+ }
@@ -0,0 +1,55 @@
1
+ import { Route, ViewType } from '@/types';
2
+ import got from '@/utils/got';
3
+ import { load } from 'cheerio';
4
+
5
+ export const route: Route = {
6
+ path: '/xna',
7
+ categories: ['bbs', 'blog'],
8
+ view: ViewType.Articles,
9
+ example: '/v2ex/xna',
10
+ parameters: {},
11
+ features: {
12
+ requireConfig: false,
13
+ requirePuppeteer: false,
14
+ antiCrawler: false,
15
+ supportBT: false,
16
+ supportPodcast: false,
17
+ supportScihub: false,
18
+ },
19
+ name: 'XNA',
20
+ maintainers: ['luckyscript'],
21
+ handler,
22
+ };
23
+
24
+ async function handler(ctx) {
25
+ const host = 'https://v2ex.com';
26
+ const pageUrl = `${host}/xna`;
27
+
28
+ const response = await got({
29
+ method: 'get',
30
+ url: pageUrl,
31
+ });
32
+
33
+ const $ = load(response.data);
34
+ const items = $('div.xna-entry-main-container')
35
+ .toArray()
36
+ .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50)
37
+ .map((dom) => {
38
+ const link = $(dom).find('.xna-entry-title > a');
39
+ const author = $(dom).find('.xna-source-author > a').text();
40
+
41
+ return {
42
+ title: $(link).text(),
43
+ link: $(link).attr('href'),
44
+ description: $(link).text(),
45
+ author,
46
+ };
47
+ });
48
+
49
+ return {
50
+ title: `V2EX-xna`,
51
+ link: pageUrl,
52
+ description: `V2EX-xna`,
53
+ item: items,
54
+ };
55
+ }
@@ -0,0 +1,6 @@
1
+ import type { Namespace } from '@/types';
2
+
3
+ export const namespace: Namespace = {
4
+ name: '华西医院',
5
+ url: 'www.wchscu.cn',
6
+ };
@@ -0,0 +1,73 @@
1
+ import { Route } from '@/types';
2
+
3
+ import got from '@/utils/got';
4
+ import { load } from 'cheerio';
5
+ import { parseDate } from '@/utils/parse-date';
6
+ import cache from '@/utils/cache';
7
+
8
+ const handler = async () => {
9
+ const rootUrl = 'https:///www.wchscu.cn';
10
+ const currentUrl = 'https://www.wchscu.cn/public/notice/recruit';
11
+ const { data: response } = await got(currentUrl);
12
+
13
+ const $ = load(response);
14
+ const list = $('div#datalist div.list div.item')
15
+ .toArray()
16
+ .map((item) => {
17
+ item = $(item);
18
+ return {
19
+ title: item.find('span.s1').text(),
20
+ pubDate: parseDate(item.find('span.s2').text()),
21
+ link: new URL(item.find('a').prop('href'), rootUrl).href,
22
+ };
23
+ });
24
+
25
+ const items = await Promise.all(
26
+ list.map((item) =>
27
+ cache.tryGet(item.link, async () => {
28
+ const { data: response } = await got(item.link);
29
+ const $ = load(response);
30
+ const newLocal = $('div.xxy3 .content');
31
+ // 选择类名为“comment-body”的第一个元素
32
+ item.description = newLocal.html();
33
+
34
+ // 上面每个列表项的每个属性都在此重用,
35
+ // 并增加了一个新属性“description”
36
+ return item;
37
+ })
38
+ )
39
+ );
40
+
41
+ return {
42
+ title: $('title').text(),
43
+ link: currentUrl,
44
+ item: items,
45
+ allowEmpty: true,
46
+ };
47
+ };
48
+
49
+ export const route: Route = {
50
+ name: '招聘公告',
51
+ path: '/recruit',
52
+ example: '/wchscu/recruit',
53
+ url: 'www.wchscu.cn',
54
+ maintainers: ['ViggoC'],
55
+ categories: ['other'],
56
+
57
+ features: {
58
+ requireConfig: false,
59
+ requirePuppeteer: false,
60
+ antiCrawler: false,
61
+ supportRadar: true,
62
+ supportBT: false,
63
+ supportPodcast: false,
64
+ supportScihub: false,
65
+ },
66
+
67
+ radar: [
68
+ {
69
+ source: ['www.wchscu.cn/public/notice/recruit'],
70
+ },
71
+ ],
72
+ handler,
73
+ };
@@ -10,9 +10,17 @@ export const route: Route = {
10
10
  target: '/user/:user_id/notes',
11
11
  },
12
12
  ],
13
- name: 'Unknown',
14
- maintainers: [],
13
+ name: '用户笔记 全文',
14
+ maintainers: ['howerhe'],
15
15
  handler,
16
+ example: '/xiaohongshu/user/52d8c541b4c4d60e6c867480/notes/fulltext',
17
+ features: {
18
+ antiCrawler: true,
19
+ requirePuppeteer: true,
20
+ },
21
+ parameters: {
22
+ user_id: 'user id, length 24 characters',
23
+ },
16
24
  };
17
25
 
18
26
  async function handler(ctx) {
@@ -5,9 +5,30 @@ import InvalidParameterError from '@/errors/types/invalid-parameter';
5
5
 
6
6
  export const route: Route = {
7
7
  path: '/user/:user_id/:category',
8
- name: 'Unknown',
9
- maintainers: [],
8
+ name: '用户笔记',
9
+ maintainers: ['lotosbin'],
10
10
  handler,
11
+ example: '/xiaohongshu/user/593032945e87e77791e03696/notes',
12
+ features: {
13
+ antiCrawler: true,
14
+ requirePuppeteer: true,
15
+ },
16
+ parameters: {
17
+ user_id: 'user id, length 24 characters',
18
+ category: {
19
+ description: 'category, notes or collect',
20
+ options: [
21
+ {
22
+ value: 'notes',
23
+ label: 'notes',
24
+ },
25
+ {
26
+ value: 'collect',
27
+ label: 'collect',
28
+ },
29
+ ],
30
+ },
31
+ },
11
32
  };
12
33
 
13
34
  async function handler(ctx) {
@@ -0,0 +1,143 @@
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
+ const baseUrl = 'https://cs.xidian.edu.cn';
8
+
9
+ const struct = {
10
+ xyxw: {
11
+ selector: {
12
+ list: '.n_wenzhang ul li',
13
+ },
14
+ name: '主页-学院新闻',
15
+ path: '/xyxw',
16
+ },
17
+ tzgg: {
18
+ selector: {
19
+ list: '.n_wenzhang ul li',
20
+ },
21
+ name: '主页-通知公告',
22
+ path: '/tzgg',
23
+ },
24
+ jlhz1: {
25
+ selector: {
26
+ list: '.n_wenzhang ul li',
27
+ },
28
+ name: '主页-交流合作',
29
+ path: '/jlhz1',
30
+ },
31
+ rsrc: {
32
+ selector: {
33
+ list: '.n_wenzhang ul li',
34
+ },
35
+ name: '主页-人事人才',
36
+ path: 'rsrc',
37
+ },
38
+ bkjy_jxxw: {
39
+ selector: {
40
+ list: '.n_wenzhang ul li',
41
+ },
42
+ name: '主页-本科生教育 / 本科教育-教学新闻',
43
+ path: 'bkjy/jxxw',
44
+ },
45
+ yjsjy_yjstz: {
46
+ selector: {
47
+ list: '.n_wenzhang ul li',
48
+ },
49
+ name: '主页-研究生教育 / 研究生教育-研究生通知',
50
+ path: 'yjsjy/yjstz',
51
+ },
52
+ jyzhaop: {
53
+ selector: {
54
+ list: '.n_wenzhang ul li',
55
+ },
56
+ name: '主页-就业招聘',
57
+ path: 'jyzhaop',
58
+ },
59
+ };
60
+
61
+ export const route: Route = {
62
+ path: '/cs/:category?',
63
+ categories: ['university'],
64
+ example: '/xidian/cs/xyxw',
65
+ parameters: { category: '通知类别,默认为主页-学院新闻' },
66
+ features: {
67
+ requireConfig: false,
68
+ requirePuppeteer: false,
69
+ antiCrawler: false,
70
+ supportBT: false,
71
+ supportPodcast: false,
72
+ supportScihub: false,
73
+ },
74
+ name: '计算机科学与技术学院',
75
+ url: 'cs.xidian.edu.cn',
76
+ maintainers: ['ZiHao256'],
77
+ handler,
78
+ description: `| 文章来源 | 参数 |
79
+ | ---------------------- | ----------- |
80
+ | ✅主页-学院新闻 | xyxw |
81
+ | ✅主页-通知公告 | tzgg |
82
+ | ✅主页-交流合作 | jlhz1 |
83
+ | ✅主页-人事人才 | rsrc |
84
+ | ✅主页-本科生教育 / 本科教育-教学新闻 | bkjy_jxxw |
85
+ | ✅主页-研究生教育 / 研究生教育-研究生通知 | yjsjy_yjstz |
86
+ | ✅主页-就业招聘 | jyzhaop |`,
87
+ radar: [
88
+ {
89
+ source: ['cs.xidian.edu.cn/'],
90
+ },
91
+ ],
92
+ };
93
+
94
+ async function handler(ctx) {
95
+ const { category = 'xyxw' } = ctx.req.param();
96
+ const url = `${baseUrl}/${struct[category].path}.htm`;
97
+ const response = await got(url, {
98
+ headers: {
99
+ referer: baseUrl,
100
+ },
101
+ https: {
102
+ rejectUnauthorized: false,
103
+ },
104
+ });
105
+
106
+ const $ = load(response.data);
107
+
108
+ let items = $(struct[category].selector.list)
109
+ .toArray()
110
+ .map((item) => {
111
+ item = $(item);
112
+ return {
113
+ title: item.find('a').text(),
114
+ link: new URL(item.find('a').attr('href'), baseUrl).href,
115
+ pubDate: parseDate(item.find('span').text()),
116
+ };
117
+ });
118
+
119
+ items = await Promise.all(
120
+ items.map((item) =>
121
+ cache.tryGet(item.link, async () => {
122
+ const detailResponse = await got(item.link, {
123
+ headers: {
124
+ referer: url,
125
+ },
126
+ https: {
127
+ rejectUnauthorized: false,
128
+ },
129
+ });
130
+ const content = load(detailResponse.data);
131
+ content('.content-sxt').remove();
132
+ item.description = content('[name="_newscontent_fromname"]').html();
133
+ return item;
134
+ })
135
+ )
136
+ );
137
+
138
+ return {
139
+ title: $('title').text(),
140
+ link: url,
141
+ item: items,
142
+ };
143
+ }