rsshub 1.0.0-master.d77d4e5 → 1.0.0-master.d7939a6

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.
@@ -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
 
@@ -13,10 +13,12 @@ const getAcwScV2ByArg1 = (arg1) => {
13
13
  }
14
14
  return res;
15
15
  };
16
- const unsbox = function (str) {
16
+ const unsbox = function (str: string) {
17
17
  const code = [15, 35, 29, 24, 33, 16, 1, 38, 10, 9, 19, 31, 40, 27, 22, 23, 25, 13, 6, 11, 39, 18, 20, 8, 14, 21, 32, 26, 2, 30, 7, 4, 17, 5, 3, 28, 34, 37, 12, 36];
18
- const res = [];
19
- for (const [i, cur] of str.entries()) {
18
+ const res: string[] = [];
19
+ // eslint-disable-next-line unicorn/no-for-loop
20
+ for (let i = 0; i < str.length; i++) {
21
+ const cur = str[i];
20
22
  for (const [j, element] of code.entries()) {
21
23
  if (element === i + 1) {
22
24
  res[j] = cur;
@@ -0,0 +1,307 @@
1
+ import { Route } from '@/types';
2
+ import { getCurrentPath } from '@/utils/helpers';
3
+ const __dirname = getCurrentPath(import.meta.url);
4
+
5
+ import cache from '@/utils/cache';
6
+ import got from '@/utils/got';
7
+ import { load } from 'cheerio';
8
+ import timezone from '@/utils/timezone';
9
+ import { parseDate } from '@/utils/parse-date';
10
+ import { art } from '@/utils/render';
11
+ import path from 'node:path';
12
+
13
+ export const handler = async (ctx) => {
14
+ const { category = 'zx/zxfb/' } = ctx.req.param();
15
+ const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 10;
16
+
17
+ const rootUrl = 'http://www.agri.cn';
18
+ const currentUrl = new URL(category.endsWith('/') ? category : `${category}/`, rootUrl).href;
19
+
20
+ const { data: response } = await got(currentUrl);
21
+
22
+ const $ = load(response);
23
+
24
+ const language = $('html').prop('lang');
25
+
26
+ let items = $('div.list_li_con, div.nxw_video_com')
27
+ .slice(0, limit)
28
+ .toArray()
29
+ .map((item) => {
30
+ item = $(item);
31
+
32
+ const a = item.find('a').first();
33
+
34
+ const title = a.text();
35
+ const image = item.find('img').first().prop('src') ? new URL(item.find('img').first().prop('src'), rootUrl).href : undefined;
36
+ const description = art(path.join(__dirname, 'templates/description.art'), {
37
+ intro: item.find('p.con_text').text() || undefined,
38
+ images: image
39
+ ? [
40
+ {
41
+ src: image,
42
+ alt: title,
43
+ },
44
+ ]
45
+ : undefined,
46
+ });
47
+
48
+ return {
49
+ title,
50
+ description,
51
+ pubDate: parseDate(item.find('span.con_date_span').text() || `${item.find('div.com_time_p2').text().trim()}${item.find('div.com_time_p1').text()}`, ['YYYY-MM-DD', 'YYYY.MM.DD']),
52
+ link: new URL(a.prop('href'), currentUrl).href,
53
+ content: {
54
+ html: description,
55
+ text: item.find('p.con_text').text() || undefined,
56
+ },
57
+ image,
58
+ banner: image,
59
+ language,
60
+ };
61
+ });
62
+
63
+ items = await Promise.all(
64
+ items.map((item) =>
65
+ cache.tryGet(item.link, async () => {
66
+ const { data: detailResponse } = await got(item.link);
67
+
68
+ const $$ = load(detailResponse);
69
+
70
+ const title = $$('div.detailCon_info_tit').text().trim();
71
+ const description = art(path.join(__dirname, 'templates/description.art'), {
72
+ description: $$('div.content_body_box').html(),
73
+ });
74
+
75
+ item.title = title;
76
+ item.description = description;
77
+ item.pubDate = timezone(parseDate($$('meta[name="publishdate"]').prop('content')), +8);
78
+ item.author = $$('meta[name="author"]').prop('content') || $$('meta[name="source"]').prop('content');
79
+ item.content = {
80
+ html: description,
81
+ text: $$('div.content_body_box').text(),
82
+ };
83
+ item.language = language;
84
+
85
+ item.enclosure_url = $$('div.content_body_box video').prop('src') ?? undefined;
86
+ item.enclosure_type = item.enclosure_url ? 'video/mp4' : undefined;
87
+ item.enclosure_title = item.enclosure_url ? title : undefined;
88
+
89
+ return item;
90
+ })
91
+ )
92
+ );
93
+
94
+ const image = new URL($('div.logo img').prop('src'), rootUrl).href;
95
+
96
+ return {
97
+ title: $('title').text(),
98
+ link: currentUrl,
99
+ item: items,
100
+ allowEmpty: true,
101
+ image,
102
+ language,
103
+ };
104
+ };
105
+
106
+ export const route: Route = {
107
+ path: '/:category{.+}?',
108
+ name: '分类',
109
+ url: 'www.agri.cn',
110
+ maintainers: ['nczitzk'],
111
+ handler,
112
+ example: '/agri/zx/zxfb',
113
+ parameters: { category: '分类,默认为 `zx/zxfb`,即最新发布,可在对应分类页 URL 中找到' },
114
+ description: `:::tip
115
+ 若订阅 [最新发布](http://www.agri.cn/zx/zxfb/),网址为 \`http://www.agri.cn/zx/zxfb/\`。截取 \`https://www.agri.cn/\` 到末尾的部分 \`zx/zxfb\` 作为参数填入,此时路由为 [\`/agri/zx/zxfb\`](https://rsshub.app/agri/zx/zxfb)。
116
+ :::
117
+
118
+ #### [机构](http://www.agri.cn/jg/)
119
+
120
+ | 分类 | ID |
121
+ | --------------------------------------- | ------------------------------------------ |
122
+ | [成果展示](http://www.agri.cn/jg/cgzs/) | [jg/cgzs](https://rsshub.app/agri/jg/cgzs) |
123
+
124
+ #### [资讯](http://www.agri.cn/zx/)
125
+
126
+ | 分类 | ID |
127
+ | ------------------------------------------- | ------------------------------------------ |
128
+ | [最新发布](http://www.agri.cn/zx/zxfb/) | [zx/zxfb](https://rsshub.app/agri/zx/zxfb) |
129
+ | [农业要闻](http://www.agri.cn/zx/nyyw/) | [zx/nyyw](https://rsshub.app/agri/zx/nyyw) |
130
+ | [中心动态](http://www.agri.cn/zx/zxdt/) | [zx/zxdt](https://rsshub.app/agri/zx/zxdt) |
131
+ | [通知公告](http://www.agri.cn/zx/hxgg/) | [zx/hxgg](https://rsshub.app/agri/zx/hxgg) |
132
+ | [全国信息联播](http://www.agri.cn/zx/xxlb/) | [zx/xxlb](https://rsshub.app/agri/zx/xxlb) |
133
+
134
+ #### [生产](http://www.agri.cn/sc/)
135
+
136
+ | 分类 | ID |
137
+ | --------------------------------------- | ------------------------------------------ |
138
+ | [生产动态](http://www.agri.cn/sc/scdt/) | [sc/scdt](https://rsshub.app/agri/sc/scdt) |
139
+ | [农业品种](http://www.agri.cn/sc/nypz/) | [sc/nypz](https://rsshub.app/agri/sc/nypz) |
140
+ | [农事指导](http://www.agri.cn/sc/nszd/) | [sc/nszd](https://rsshub.app/agri/sc/nszd) |
141
+ | [农业气象](http://www.agri.cn/sc/nyqx/) | [sc/nyqx](https://rsshub.app/agri/sc/nyqx) |
142
+ | [专项监测](http://www.agri.cn/sc/zxjc/) | [sc/zxjc](https://rsshub.app/agri/sc/zxjc) |
143
+
144
+ #### [数据](http://www.agri.cn/sj/)
145
+
146
+ | 分类 | ID |
147
+ | --------------------------------------- | ------------------------------------------ |
148
+ | [市场动态](http://www.agri.cn/sj/scdt/) | [sj/scdt](https://rsshub.app/agri/sj/scdt) |
149
+ | [供需形势](http://www.agri.cn/sj/gxxs/) | [sj/gxxs](https://rsshub.app/agri/sj/gxxs) |
150
+ | [监测预警](http://www.agri.cn/sj/jcyj/) | [sj/jcyj](https://rsshub.app/agri/sj/jcyj) |
151
+
152
+ #### [信息化](http://www.agri.cn/xxh/)
153
+
154
+ | 分类 | ID |
155
+ | ---------------------------------------------- | ------------------------------------------------ |
156
+ | [智慧农业](http://www.agri.cn/xxh/zhny/) | [xxh/zhny](https://rsshub.app/agri/xxh/zhny) |
157
+ | [信息化标准](http://www.agri.cn/xxh/xxhbz/) | [xxh/xxhbz](https://rsshub.app/agri/xxh/xxhbz) |
158
+ | [中国乡村资讯](http://www.agri.cn/xxh/zgxczx/) | [xxh/zgxczx](https://rsshub.app/agri/xxh/zgxczx) |
159
+
160
+ #### [视频](http://www.agri.cn/video/)
161
+
162
+ | 分类 | ID |
163
+ | -------------------------------------------------- | ---------------------------------------------------------------- |
164
+ | [新闻资讯](http://www.agri.cn/video/xwzx/nyxw/) | [video/xwzx/nyxw](https://rsshub.app/agri/video/xwzx/nyxw) |
165
+ | [致富天地](http://www.agri.cn/video/zftd/) | [video/zftd](https://rsshub.app/agri/video/zftd) |
166
+ | [地方农业](http://www.agri.cn/video/dfny/beijing/) | [video/dfny/beijing](https://rsshub.app/agri/video/dfny/beijing) |
167
+ | [气象农业](http://www.agri.cn/video/qxny/) | [video/qxny](https://rsshub.app/agri/video/qxny) |
168
+ | [讲座培训](http://www.agri.cn/video/jzpx/) | [video/jzpx](https://rsshub.app/agri/video/jzpx) |
169
+ | [文化生活](http://www.agri.cn/video/whsh/) | [video/whsh](https://rsshub.app/agri/video/whsh) |
170
+ `,
171
+ categories: ['new-media'],
172
+
173
+ features: {
174
+ requireConfig: false,
175
+ requirePuppeteer: false,
176
+ antiCrawler: false,
177
+ supportRadar: true,
178
+ supportBT: false,
179
+ supportPodcast: false,
180
+ supportScihub: false,
181
+ },
182
+ radar: [
183
+ {
184
+ source: ['www.agri.cn/:category?'],
185
+ target: (params) => {
186
+ const category = params.category;
187
+
188
+ return category ? `/${category}` : '';
189
+ },
190
+ },
191
+ {
192
+ title: '机构 - 成果展示',
193
+ source: ['www.agri.cn/jg/cgzs/'],
194
+ target: '/jg/cgzs',
195
+ },
196
+ {
197
+ title: '资讯 - 最新发布',
198
+ source: ['www.agri.cn/zx/zxfb/'],
199
+ target: '/zx/zxfb',
200
+ },
201
+ {
202
+ title: '资讯 - 农业要闻',
203
+ source: ['www.agri.cn/zx/nyyw/'],
204
+ target: '/zx/nyyw',
205
+ },
206
+ {
207
+ title: '资讯 - 中心动态',
208
+ source: ['www.agri.cn/zx/zxdt/'],
209
+ target: '/zx/zxdt',
210
+ },
211
+ {
212
+ title: '资讯 - 通知公告',
213
+ source: ['www.agri.cn/zx/hxgg/'],
214
+ target: '/zx/hxgg',
215
+ },
216
+ {
217
+ title: '资讯 - 全国信息联播',
218
+ source: ['www.agri.cn/zx/xxlb/'],
219
+ target: '/zx/xxlb',
220
+ },
221
+ {
222
+ title: '生产 - 生产动态',
223
+ source: ['www.agri.cn/sc/scdt/'],
224
+ target: '/sc/scdt',
225
+ },
226
+ {
227
+ title: '生产 - 农业品种',
228
+ source: ['www.agri.cn/sc/nypz/'],
229
+ target: '/sc/nypz',
230
+ },
231
+ {
232
+ title: '生产 - 农事指导',
233
+ source: ['www.agri.cn/sc/nszd/'],
234
+ target: '/sc/nszd',
235
+ },
236
+ {
237
+ title: '生产 - 农业气象',
238
+ source: ['www.agri.cn/sc/nyqx/'],
239
+ target: '/sc/nyqx',
240
+ },
241
+ {
242
+ title: '生产 - 专项监测',
243
+ source: ['www.agri.cn/sc/zxjc/'],
244
+ target: '/sc/zxjc',
245
+ },
246
+ {
247
+ title: '数据 - 市场动态',
248
+ source: ['www.agri.cn/sj/scdt/'],
249
+ target: '/sj/scdt',
250
+ },
251
+ {
252
+ title: '数据 - 供需形势',
253
+ source: ['www.agri.cn/sj/gxxs/'],
254
+ target: '/sj/gxxs',
255
+ },
256
+ {
257
+ title: '数据 - 监测预警',
258
+ source: ['www.agri.cn/sj/jcyj/'],
259
+ target: '/sj/jcyj',
260
+ },
261
+ {
262
+ title: '信息化 - 智慧农业',
263
+ source: ['www.agri.cn/xxh/zhny/'],
264
+ target: '/xxh/zhny',
265
+ },
266
+ {
267
+ title: '信息化 - 信息化标准',
268
+ source: ['www.agri.cn/xxh/xxhbz/'],
269
+ target: '/xxh/xxhbz',
270
+ },
271
+ {
272
+ title: '信息化 - 中国乡村资讯',
273
+ source: ['www.agri.cn/xxh/zgxczx/'],
274
+ target: '/xxh/zgxczx',
275
+ },
276
+ {
277
+ title: '视频 - 新闻资讯',
278
+ source: ['www.agri.cn/video/xwzx/nyxw/'],
279
+ target: '/video/xwzx/nyxw',
280
+ },
281
+ {
282
+ title: '视频 - 致富天地',
283
+ source: ['www.agri.cn/video/zftd/'],
284
+ target: '/video/zftd',
285
+ },
286
+ {
287
+ title: '视频 - 地方农业',
288
+ source: ['www.agri.cn/video/dfny/beijing/'],
289
+ target: '/video/dfny/beijing',
290
+ },
291
+ {
292
+ title: '视频 - 气象农业',
293
+ source: ['www.agri.cn/video/qxny/'],
294
+ target: '/video/qxny',
295
+ },
296
+ {
297
+ title: '视频 - 讲座培训',
298
+ source: ['www.agri.cn/video/jzpx/'],
299
+ target: '/video/jzpx',
300
+ },
301
+ {
302
+ title: '视频 - 文化生活',
303
+ source: ['www.agri.cn/video/whsh/'],
304
+ target: '/video/whsh',
305
+ },
306
+ ],
307
+ };
@@ -0,0 +1,8 @@
1
+ import type { Namespace } from '@/types';
2
+
3
+ export const namespace: Namespace = {
4
+ name: '中国农业农村信息网',
5
+ url: 'agri.cn',
6
+ categories: ['new-media'],
7
+ description: '',
8
+ };
@@ -0,0 +1,21 @@
1
+ {{ if images }}
2
+ {{ each images image }}
3
+ {{ if image?.src }}
4
+ <figure>
5
+ <img
6
+ {{ if image.alt }}
7
+ alt="{{ image.alt }}"
8
+ {{ /if }}
9
+ src="{{ image.src }}">
10
+ </figure>
11
+ {{ /if }}
12
+ {{ /each }}
13
+ {{ /if }}
14
+
15
+ {{ if intro }}
16
+ <blockquote>{{ intro }}</blockquote>
17
+ {{ /if }}
18
+
19
+ {{ if description }}
20
+ {{@ description }}
21
+ {{ /if }}