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
@@ -1,13 +1,10 @@
1
1
  import { namespaces } from '@/registry';
2
2
  import { parse } from 'tldts';
3
- import { RadarItem } from '@/types';
3
+ import { RadarDomain } from '@/types';
4
4
  import { createRoute, RouteHandler } from '@hono/zod-openapi';
5
5
 
6
6
  const radar: {
7
- [domain: string]: {
8
- _name: string;
9
- [subdomain: string]: RadarItem[] | string;
10
- };
7
+ [domain: string]: RadarDomain;
11
8
  } = {};
12
9
 
13
10
  for (const namespace in namespaces) {
@@ -23,7 +20,7 @@ for (const namespace in namespaces) {
23
20
  if (!radar[domain]) {
24
21
  radar[domain] = {
25
22
  _name: namespaces[namespace].name,
26
- };
23
+ } as RadarDomain;
27
24
  }
28
25
  if (!radar[domain][subdomain]) {
29
26
  radar[domain][subdomain] = [];
@@ -1,13 +1,10 @@
1
1
  import { namespaces } from '@/registry';
2
2
  import { parse } from 'tldts';
3
- import { RadarItem } from '@/types';
3
+ import { RadarDomain } from '@/types';
4
4
  import { z, createRoute, RouteHandler } from '@hono/zod-openapi';
5
5
 
6
6
  const radar: {
7
- [domain: string]: {
8
- _name: string;
9
- [subdomain: string]: RadarItem[] | string;
10
- };
7
+ [domain: string]: RadarDomain;
11
8
  } = {};
12
9
 
13
10
  for (const namespace in namespaces) {
@@ -23,7 +20,7 @@ for (const namespace in namespaces) {
23
20
  if (!radar[domain]) {
24
21
  radar[domain] = {
25
22
  _name: namespaces[namespace].name,
26
- };
23
+ } as RadarDomain;
27
24
  }
28
25
  if (!radar[domain][subdomain]) {
29
26
  radar[domain][subdomain] = [];
package/lib/config.ts CHANGED
@@ -70,7 +70,9 @@ export type Config = {
70
70
  temperature?: number;
71
71
  maxTokens?: number;
72
72
  endpoint: string;
73
- prompt?: string;
73
+ inputOption: string;
74
+ promptTitle: string;
75
+ promptDescription: string;
74
76
  };
75
77
  bilibili: {
76
78
  cookies: Record<string, string | undefined>;
@@ -168,6 +170,9 @@ export type Config = {
168
170
  javdb: {
169
171
  session?: string;
170
172
  };
173
+ keylol: {
174
+ cookie?: string;
175
+ };
171
176
  lastfm: {
172
177
  api_key?: string;
173
178
  };
@@ -433,7 +438,9 @@ const calculateValue = () => {
433
438
  temperature: toInt(envs.OPENAI_TEMPERATURE, 0.2),
434
439
  maxTokens: toInt(envs.OPENAI_MAX_TOKENS, 0) || undefined,
435
440
  endpoint: envs.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1',
436
- prompt: envs.OPENAI_PROMPT || 'Please summarize the following article and reply with markdown format.',
441
+ inputOption: envs.OPENAI_INPUT_OPTION || 'description',
442
+ promptDescription: envs.OPENAI_PROMPT || 'Please summarize the following article and reply with markdown format.',
443
+ promptTitle: envs.OPENAI_PROMPT_TITLE || 'Please translate the following title into Simplified Chinese and reply only translated text.',
437
444
  },
438
445
 
439
446
  // Route-specific Configurations
@@ -534,6 +541,9 @@ const calculateValue = () => {
534
541
  javdb: {
535
542
  session: envs.JAVDB_SESSION,
536
543
  },
544
+ keylol: {
545
+ cookie: envs.KEYLOL_COOKIE,
546
+ },
537
547
  lastfm: {
538
548
  api_key: envs.LASTFM_API_KEY,
539
549
  },
@@ -713,26 +723,6 @@ calculateValue();
713
723
  logger.error('Remote config load failed.', error);
714
724
  }
715
725
  }
716
-
717
- if (!envs.DISABLE_UMAMI && envs.NODE_ENV === 'production') {
718
- ofetch(`https://umami.rss3.io/api/send`, {
719
- method: 'POST',
720
- headers: {
721
- 'content-type': 'application/json',
722
- 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
723
- },
724
- body: JSON.stringify({
725
- payload: {
726
- hostname: 'rsshub.app',
727
- language: 'en-US',
728
- referrer: 'rsshub.app',
729
- url: 'rsshub.app',
730
- website: '239067cd-231f-4a3f-a478-cced11a84876',
731
- },
732
- type: 'event',
733
- }),
734
- });
735
- }
736
726
  })();
737
727
 
738
728
  // @ts-expect-error value is set
@@ -69,7 +69,7 @@ export const errorHandler: ErrorHandler = (error, ctx) => {
69
69
  logger.error(`Error in ${requestPath}: ${message}`);
70
70
  requestMetric.error({ path: requestPath, method: ctx.req.method, status: ctx.res.status });
71
71
 
72
- return config.isPackage
72
+ return config.isPackage || ctx.req.query('format') === 'json'
73
73
  ? ctx.json({
74
74
  error: {
75
75
  message: error.message ?? error,
package/lib/index.ts CHANGED
@@ -18,7 +18,7 @@ if (config.listenInaddrAny) {
18
18
 
19
19
  const server = serve({
20
20
  fetch: app.fetch,
21
- hostname: config.listenInaddrAny ? undefined : '127.0.0.1',
21
+ hostname: config.listenInaddrAny ? '::' : '127.0.0.1',
22
22
  port,
23
23
  });
24
24
 
@@ -116,6 +116,148 @@ const expects = {
116
116
  desc: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
117
117
  },
118
118
  },
119
+ extraComplicated: {
120
+ origin: {
121
+ items: [
122
+ {
123
+ content:
124
+ '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n\n<a href="http://mock.com/DIYgod/RSSHub"></a>\n<img src="https://mock.com/DIYgod/RSSHub.jpg" data-src="/DIYgod/RSSHub0.jpg" referrerpolicy="no-referrer">\n<img data-src="/DIYgod/RSSHub.jpg" src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<img data-mock="/DIYgod/RSSHub.png" src="https://mock.com/DIYgod/RSSHub.png" referrerpolicy="no-referrer">\n<img mock="/DIYgod/RSSHub.gif" src="https://mock.com/DIYgod/RSSHub.gif" referrerpolicy="no-referrer">\n<img src="http://mock.com/DIYgod/DIYgod/RSSHub" referrerpolicy="no-referrer">\n<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" referrerpolicy="no-referrer">',
125
+ itunes: {},
126
+ },
127
+ {
128
+ content: '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">',
129
+ itunes: {},
130
+ },
131
+ {
132
+ content:
133
+ '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" referrerpolicy="no-referrer">',
134
+ enclosure: {
135
+ url: 'https://mock.com/DIYgod/RSSHub.png',
136
+ type: 'image/png',
137
+ },
138
+ itunes: {
139
+ image: 'https://mock.com/DIYgod/RSSHub.gif',
140
+ },
141
+ },
142
+ ],
143
+ image: {
144
+ link: 'https://github.com/DIYgod/RSSHub',
145
+ url: 'https://mock.com/DIYgod/RSSHub.png',
146
+ title: 'Test complicated',
147
+ },
148
+ description: '<img src="http://mock.com/DIYgod/DIYgod/RSSHub"> - Powered by RSSHub',
149
+ },
150
+ processed: {
151
+ items: [
152
+ {
153
+ content:
154
+ '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n\n<a href="http://mock.com/DIYgod/RSSHub"></a>\n<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" data-src="/DIYgod/RSSHub0.jpg" referrerpolicy="no-referrer">\n<img data-src="/DIYgod/RSSHub.jpg" src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<img data-mock="/DIYgod/RSSHub.png" src="https://i3.wp.com/mock.com/DIYgod/RSSHub.png" referrerpolicy="no-referrer">\n<img mock="/DIYgod/RSSHub.gif" src="https://i3.wp.com/mock.com/DIYgod/RSSHub.gif" referrerpolicy="no-referrer">\n<img src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub" referrerpolicy="no-referrer">\n<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" referrerpolicy="no-referrer">',
155
+ itunes: {},
156
+ },
157
+ {
158
+ content: '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">',
159
+ itunes: {},
160
+ },
161
+ {
162
+ content:
163
+ '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" referrerpolicy="no-referrer">',
164
+ enclosure: {
165
+ url: 'https://i3.wp.com/mock.com/DIYgod/RSSHub.png',
166
+ type: 'image/png',
167
+ },
168
+ itunes: {
169
+ image: 'https://i3.wp.com/mock.com/DIYgod/RSSHub.gif',
170
+ },
171
+ },
172
+ ],
173
+ image: {
174
+ link: 'https://github.com/DIYgod/RSSHub',
175
+ url: 'https://i3.wp.com/mock.com/DIYgod/RSSHub.png',
176
+ title: 'Test complicated',
177
+ },
178
+ description: '<img src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"> - Powered by RSSHub',
179
+ },
180
+ urlencoded: {
181
+ items: [
182
+ {
183
+ content:
184
+ '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" referrerpolicy="no-referrer">\n\n<a href="http://mock.com/DIYgod/RSSHub"></a>\n<img src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" data-src="/DIYgod/RSSHub0.jpg" referrerpolicy="no-referrer">\n<img data-src="/DIYgod/RSSHub.jpg" src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" referrerpolicy="no-referrer">\n<img data-mock="/DIYgod/RSSHub.png" src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.png" referrerpolicy="no-referrer">\n<img mock="/DIYgod/RSSHub.gif" src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.gif" referrerpolicy="no-referrer">\n<img src="https://images.weserv.nl?url=http%3A%2F%2Fmock.com%2FDIYgod%2FDIYgod%2FRSSHub" referrerpolicy="no-referrer">\n<img src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" referrerpolicy="no-referrer">\n<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" referrerpolicy="no-referrer">',
185
+ itunes: {},
186
+ },
187
+ {
188
+ content: '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" referrerpolicy="no-referrer">',
189
+ itunes: {},
190
+ },
191
+ {
192
+ content:
193
+ '<a href="https://mock.com/DIYgod/RSSHub"></a>\n<img src="https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.jpg" referrerpolicy="no-referrer">\n<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" referrerpolicy="no-referrer">',
194
+ enclosure: {
195
+ url: 'https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.png',
196
+ type: 'image/png',
197
+ },
198
+ itunes: {
199
+ image: 'https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.gif',
200
+ },
201
+ },
202
+ ],
203
+ image: {
204
+ link: 'https://github.com/DIYgod/RSSHub',
205
+ url: 'https://images.weserv.nl?url=https%3A%2F%2Fmock.com%2FDIYgod%2FRSSHub.png',
206
+ title: 'Test complicated',
207
+ },
208
+ description: '<img src="https://images.weserv.nl?url=http%3A%2F%2Fmock.com%2FDIYgod%2FDIYgod%2FRSSHub"> - Powered by RSSHub',
209
+ },
210
+ },
211
+ extraMultimedia: {
212
+ origin: {
213
+ items: [
214
+ {
215
+ content:
216
+ '<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<video src="https://mock.com/DIYgod/RSSHub.mp4"></video>\n<video poster="https://mock.com/DIYgod/RSSHub.jpg">\n<source src="https://mock.com/DIYgod/RSSHub.mp4" type="video/mp4">\n<source src="https://mock.com/DIYgod/RSSHub.webm" type="video/webm">\n</video>\n<audio src="https://mock.com/DIYgod/RSSHub.mp3"></audio>\n<iframe src="https://mock.com/DIYgod/RSSHub.html" referrerpolicy="no-referrer"></iframe>',
217
+ },
218
+ {
219
+ content: '<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<video src="https://mock.com/DIYgod/RSSHub.mp4"></video>',
220
+ enclosure: {
221
+ url: 'https://mock.com/DIYgod/RSSHub.mp4',
222
+ type: 'video/mp4',
223
+ },
224
+ },
225
+ ],
226
+ description: '<video src="http://mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
227
+ },
228
+ relayed: {
229
+ items: [
230
+ {
231
+ content:
232
+ '<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<video src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4"></video>\n<video poster="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg">\n<source src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4" type="video/mp4">\n<source src="https://i3.wp.com/mock.com/DIYgod/RSSHub.webm" type="video/webm">\n</video>\n<audio src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp3"></audio>\n<iframe src="https://mock.com/DIYgod/RSSHub.html" referrerpolicy="no-referrer"></iframe>',
233
+ },
234
+ {
235
+ content: '<img src="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<video src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4"></video>',
236
+ enclosure: {
237
+ url: 'https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4',
238
+ type: 'video/mp4',
239
+ },
240
+ },
241
+ ],
242
+ description: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
243
+ },
244
+ partlyRelayed: {
245
+ items: [
246
+ {
247
+ content:
248
+ '<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<video src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4"></video>\n<video poster="https://i3.wp.com/mock.com/DIYgod/RSSHub.jpg">\n<source src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4" type="video/mp4">\n<source src="https://i3.wp.com/mock.com/DIYgod/RSSHub.webm" type="video/webm">\n</video>\n<audio src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp3"></audio>\n<iframe src="https://mock.com/DIYgod/RSSHub.html" referrerpolicy="no-referrer"></iframe>',
249
+ },
250
+ {
251
+ content: '<img src="https://mock.com/DIYgod/RSSHub.jpg" referrerpolicy="no-referrer">\n<video src="https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4"></video>',
252
+ enclosure: {
253
+ url: 'https://i3.wp.com/mock.com/DIYgod/RSSHub.mp4',
254
+ type: 'video/mp4',
255
+ },
256
+ },
257
+ ],
258
+ description: '<video src="https://i3.wp.com/mock.com/DIYgod/DIYgod/RSSHub"></video> - Powered by RSSHub',
259
+ },
260
+ },
119
261
  };
120
262
 
121
263
  const testAntiHotlink = async (path, expectObj, query?: string | Record<string, any>) => {
@@ -142,12 +284,55 @@ const testAntiHotlink = async (path, expectObj, query?: string | Record<string,
142
284
  return parsed;
143
285
  };
144
286
 
145
- const expectImgOrigin = (query?: string | Record<string, any>) => testAntiHotlink('/test/complicated', expects.complicated.origin, query);
146
- const expectImgProcessed = (query?: string | Record<string, any>) => testAntiHotlink('/test/complicated', expects.complicated.processed, query);
147
- const expectImgUrlencoded = (query?: string | Record<string, any>) => testAntiHotlink('/test/complicated', expects.complicated.urlencoded, query);
148
- const expectMultimediaOrigin = (query?: string | Record<string, any>) => testAntiHotlink('/test/multimedia', expects.multimedia.origin, query);
149
- const expectMultimediaRelayed = (query?: string | Record<string, any>) => testAntiHotlink('/test/multimedia', expects.multimedia.relayed, query);
150
- const expectMultimediaPartlyRelayed = (query?: string | Record<string, any>) => testAntiHotlink('/test/multimedia', expects.multimedia.partlyRelayed, query);
287
+ const testAntiHotlinkExtra = async (path, expectObj, query?: string | Record<string, any>) => {
288
+ const app = (await import('@/app')).default;
289
+
290
+ path += query ? `?${new URLSearchParams(query).toString()}` : '';
291
+
292
+ const response = await app.request(path);
293
+ const parsed = await parser.parseString(await response.text());
294
+ const obj = {
295
+ description: parsed.description,
296
+ image: parsed.image,
297
+ items: parsed.items.slice(0, expectObj.items.length).map((e) => ({
298
+ content: e.content,
299
+ enclosure: e.enclosure,
300
+ itunes: e.itunes,
301
+ })),
302
+ };
303
+ expect(obj).toEqual(expectObj);
304
+
305
+ return parsed;
306
+ };
307
+
308
+ const expectImgOrigin = async (query?: string | Record<string, any>) => {
309
+ await testAntiHotlink('/test/complicated', expects.complicated.origin, query);
310
+ await testAntiHotlinkExtra('/test/complicated', expects.extraComplicated.origin, query);
311
+ };
312
+ const expectImgProcessed = async (query?: string | Record<string, any>) => {
313
+ await testAntiHotlink('/test/complicated', expects.complicated.processed, query);
314
+ await testAntiHotlinkExtra('/test/complicated', expects.extraComplicated.processed, query);
315
+ };
316
+
317
+ const expectImgUrlencoded = async (query?: string | Record<string, any>) => {
318
+ await testAntiHotlink('/test/complicated', expects.complicated.urlencoded, query);
319
+ await testAntiHotlinkExtra('/test/complicated', expects.extraComplicated.urlencoded, query);
320
+ };
321
+
322
+ const expectMultimediaOrigin = async (query?: string | Record<string, any>) => {
323
+ await testAntiHotlink('/test/multimedia', expects.multimedia.origin, query);
324
+ await testAntiHotlinkExtra('/test/multimedia', expects.extraMultimedia.origin, query);
325
+ };
326
+
327
+ const expectMultimediaRelayed = async (query?: string | Record<string, any>) => {
328
+ await testAntiHotlink('/test/multimedia', expects.multimedia.relayed, query);
329
+ await testAntiHotlinkExtra('/test/multimedia', expects.extraMultimedia.relayed, query);
330
+ };
331
+
332
+ const expectMultimediaPartlyRelayed = async (query?: string | Record<string, any>) => {
333
+ await testAntiHotlink('/test/multimedia', expects.multimedia.partlyRelayed, query);
334
+ await testAntiHotlinkExtra('/test/multimedia', expects.extraMultimedia.partlyRelayed, query);
335
+ };
151
336
 
152
337
  describe('anti-hotlink', () => {
153
338
  it('template-legacy', async () => {
@@ -44,6 +44,18 @@ const parseUrl = (str: string) => {
44
44
 
45
45
  return url;
46
46
  };
47
+
48
+ const replaceUrl = (template?: string, url?: string) => {
49
+ if (!template || !url) {
50
+ return url;
51
+ }
52
+ const oldUrl = parseUrl(url);
53
+ if (oldUrl && oldUrl.protocol !== 'data:') {
54
+ return interpolate(template, oldUrl);
55
+ }
56
+ return url;
57
+ };
58
+
47
59
  const replaceUrls = ($: CheerioAPI, selector: string, template: string, attribute = 'src') => {
48
60
  $(selector).each(function () {
49
61
  const oldSrc = $(this).attr(attribute);
@@ -120,6 +132,9 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
120
132
  // image link
121
133
  const data: Data = ctx.get('data');
122
134
  if (data) {
135
+ if (data.image) {
136
+ data.image = replaceUrl(imageHotlinkTemplate, data.image);
137
+ }
123
138
  if (data.description) {
124
139
  data.description = process(data.description, imageHotlinkTemplate, multimediaHotlinkTemplate);
125
140
  }
@@ -129,6 +144,19 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
129
144
  if (item.description) {
130
145
  item.description = process(item.description, imageHotlinkTemplate, multimediaHotlinkTemplate);
131
146
  }
147
+ if (item.enclosure_url && item.enclosure_type) {
148
+ if (item.enclosure_type.startsWith('image/')) {
149
+ item.enclosure_url = replaceUrl(imageHotlinkTemplate, item.enclosure_url);
150
+ } else if (/^(video|audio)\//.test(item.enclosure_type)) {
151
+ item.enclosure_url = replaceUrl(multimediaHotlinkTemplate, item.enclosure_url);
152
+ }
153
+ }
154
+ if (item.image) {
155
+ item.image = replaceUrl(imageHotlinkTemplate, item.image);
156
+ }
157
+ if (item.itunes_item_image) {
158
+ item.itunes_item_image = replaceUrl(imageHotlinkTemplate, item.itunes_item_image);
159
+ }
132
160
  }
133
161
  }
134
162
 
@@ -427,7 +427,8 @@ describe('multi parameter', () => {
427
427
  });
428
428
 
429
429
  describe('openai', () => {
430
- it(`chatgpt`, async () => {
430
+ it('processes both title and description', async () => {
431
+ config.openai.inputOption = 'both';
431
432
  const responseWithGpt = await app.request('/test/gpt?chatgpt=true');
432
433
  const responseNormal = await app.request('/test/gpt');
433
434
 
@@ -437,9 +438,25 @@ describe('openai', () => {
437
438
  const parsedGpt = await parser.parseString(await responseWithGpt.text());
438
439
  const parsedNormal = await parser.parseString(await responseNormal.text());
439
440
 
440
- expect(parsedGpt.items[0].content).not.toBe(undefined);
441
- expect(parsedGpt.items[0].content).toBe(parsedNormal.items[0].content);
442
- expect(parsedGpt.items[1].content).not.toBe(undefined);
443
- expect(parsedGpt.items[1].content).not.toBe(parsedNormal.items[1].content);
441
+ expect(parsedGpt.items[0].title).not.toBe(parsedNormal.items[0].title);
442
+ expect(parsedGpt.items[0].title).toContain('AI processed content.');
443
+ expect(parsedGpt.items[0].content).not.toBe(parsedNormal.items[0].content);
444
+ expect(parsedGpt.items[0].content).toContain('AI processed content.');
445
+ });
446
+
447
+ it('processes title or description', async () => {
448
+ // test title
449
+ config.openai.inputOption = 'title';
450
+ const responseTitleOnly = await app.request('/test/gpt?chatgpt=true');
451
+ const parsedTitleOnly = await parser.parseString(await responseTitleOnly.text());
452
+ expect(parsedTitleOnly.items[0].title).toContain('AI processed content.');
453
+ expect(parsedTitleOnly.items[0].content).not.toContain('AI processed content.');
454
+
455
+ // test description
456
+ config.openai.inputOption = 'description';
457
+ const responseDescriptionOnly = await app.request('/test/gpt?chatgpt=true');
458
+ const parsedDescriptionOnly = await parser.parseString(await responseDescriptionOnly.text());
459
+ expect(parsedDescriptionOnly.items[0].title).not.toContain('AI processed content.');
460
+ expect(parsedDescriptionOnly.items[0].content).toContain('AI processed content.');
444
461
  });
445
462
  });
@@ -32,7 +32,7 @@ const resolveRelativeLink = ($: CheerioAPI, elem: Element, attr: string, baseUrl
32
32
  }
33
33
  };
34
34
 
35
- const summarizeArticle = async (articleText: string) => {
35
+ const getAiCompletion = async (prompt: string, text: string) => {
36
36
  const apiUrl = `${config.openai.endpoint}/chat/completions`;
37
37
  const response = await ofetch(apiUrl, {
38
38
  method: 'POST',
@@ -40,8 +40,8 @@ const summarizeArticle = async (articleText: string) => {
40
40
  model: config.openai.model,
41
41
  max_tokens: config.openai.maxTokens,
42
42
  messages: [
43
- { role: 'system', content: config.openai.prompt },
44
- { role: 'user', content: articleText },
43
+ { role: 'system', content: prompt },
44
+ { role: 'user', content: text },
45
45
  ],
46
46
  temperature: config.openai.temperature,
47
47
  },
@@ -327,23 +327,53 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
327
327
  if (ctx.req.query('chatgpt') && config.openai.apiKey) {
328
328
  data.item = await Promise.all(
329
329
  data.item.map(async (item) => {
330
- if (item.description) {
331
- try {
332
- const summary = await cache.tryGet(`openai:${item.link}`, async () => {
333
- const text = convert(item.description!);
334
- if (text.length < 300) {
335
- return '';
336
- }
337
- const summary_md = await summarizeArticle(text);
338
- return md.render(summary_md);
330
+ try {
331
+ // handle description
332
+ if (config.openai.inputOption === 'description' && item.description) {
333
+ const description = await cache.tryGet(`openai:description:${item.link}`, async () => {
334
+ const description = convert(item.description!);
335
+ const descriptionMd = await getAiCompletion(config.openai.promptDescription, description);
336
+ return md.render(descriptionMd);
339
337
  });
340
- // 将总结结果添加到文章数据中
341
- if (summary !== '') {
342
- item.description = summary + '<hr/><br/>' + item.description;
338
+ // add it to the description
339
+ if (description !== '') {
340
+ item.description = description + '<hr/><br/>' + item.description;
341
+ }
342
+ }
343
+ // handle title
344
+ else if (config.openai.inputOption === 'title' && item.title) {
345
+ const title = await cache.tryGet(`openai:title:${item.link}`, async () => {
346
+ const title = convert(item.title!);
347
+ return await getAiCompletion(config.openai.promptTitle, title);
348
+ });
349
+ // replace the title
350
+ if (title !== '') {
351
+ item.title = title + '';
352
+ }
353
+ }
354
+ // handle both
355
+ else if (config.openai.inputOption === 'both' && item.title && item.description) {
356
+ const title = await cache.tryGet(`openai:title:${item.link}`, async () => {
357
+ const title = convert(item.title!);
358
+ return await getAiCompletion(config.openai.promptTitle, title);
359
+ });
360
+ // replace the title
361
+ if (title !== '') {
362
+ item.title = title + '';
363
+ }
364
+
365
+ const description = await cache.tryGet(`openai:description:${item.link}`, async () => {
366
+ const description = convert(item.description!);
367
+ const descriptionMd = await getAiCompletion(config.openai.promptDescription, description);
368
+ return md.render(descriptionMd);
369
+ });
370
+ // add it to the description
371
+ if (description !== '') {
372
+ item.description = description + '<hr/><br/>' + item.description;
343
373
  }
344
- } catch {
345
- // when openai failed, return default description and not write cache
346
374
  }
375
+ } catch {
376
+ // when openai failed, return default content and not write cache
347
377
  }
348
378
  return item;
349
379
  })
@@ -29,4 +29,12 @@ describe('registry', () => {
29
29
  const response = await app.request('/favicon.ico');
30
30
  expect(response.status).toBe(200);
31
31
  });
32
+
33
+ // healthz
34
+ it('/healthz', async () => {
35
+ const response = await app.request('/healthz');
36
+ expect(response.status).toBe(200);
37
+ expect(response.headers.get('cache-control')).toBe('no-cache');
38
+ expect(await response.text()).toBe('ok');
39
+ });
32
40
  });
package/lib/registry.ts CHANGED
@@ -7,6 +7,7 @@ import { serveStatic } from '@hono/node-server/serve-static';
7
7
  import { config } from '@/config';
8
8
 
9
9
  import index from '@/routes/index';
10
+ import healthz from '@/routes/healthz';
10
11
  import robotstxt from '@/routes/robots.txt';
11
12
  import metrics from '@/routes/metrics';
12
13
 
@@ -100,6 +101,7 @@ for (const namespace in namespaces) {
100
101
  }
101
102
 
102
103
  app.get('/', index);
104
+ app.get('/healthz', healthz);
103
105
  app.get('/robots.txt', robotstxt);
104
106
  if (config.debugInfo) {
105
107
  // Only enable tracing in debug mode
package/lib/router.js CHANGED
@@ -66,9 +66,6 @@ router.get('/konachan.net/post/popular_recent/:period', lazyloadRouteHandler('./
66
66
  // EZTV
67
67
  router.get('/eztv/torrents/:imdb_id', lazyloadRouteHandler('./routes/eztv/imdb'));
68
68
 
69
- // 新京报
70
- router.get('/bjnews/:cat', lazyloadRouteHandler('./routes/bjnews/news'));
71
-
72
69
  // 米哈游
73
70
  router.get('/mihoyo/bh3/:type', lazyloadRouteHandler('./routes/mihoyo/bh3'));
74
71
  router.get('/mihoyo/bh2/:type', lazyloadRouteHandler('./routes/mihoyo/bh2'));