rsshub 1.0.0-master.d62365e → 1.0.0-master.d72dce4

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 (102) hide show
  1. package/lib/config.js +3 -0
  2. package/lib/middleware/parameter.js +3 -1
  3. package/lib/radar-rules.js +0 -144
  4. package/lib/router.js +2 -56
  5. package/lib/routes/ehentai/ehapi.js +0 -1
  6. package/lib/routes/universities/sjtu/jwc.js +51 -53
  7. package/lib/routes/yxdzqb/index.js +5 -5
  8. package/lib/routes/zhihu/collection.js +26 -2
  9. package/lib/routes/zhihu/pin/utils.js +17 -7
  10. package/lib/routes/zhihu/posts.js +2 -1
  11. package/lib/routes/zhihu/topic.js +10 -2
  12. package/lib/routes/zhihu/zhuanlan.js +12 -1
  13. package/lib/v2/consumer/index.js +55 -0
  14. package/lib/v2/consumer/maintainer.js +3 -0
  15. package/lib/v2/consumer/radar.js +13 -0
  16. package/lib/v2/consumer/router.js +3 -0
  17. package/lib/{routes → v2}/dockerhub/build.js +3 -1
  18. package/lib/v2/dockerhub/maintainer.js +4 -0
  19. package/lib/v2/dockerhub/radar.js +19 -0
  20. package/lib/v2/dockerhub/router.js +4 -0
  21. package/lib/v2/dockerhub/tag.js +33 -0
  22. package/lib/v2/dockerhub/utils.js +10 -0
  23. package/lib/{routes → v2}/douban/book/rank.js +0 -0
  24. package/lib/{routes → v2}/douban/channel/subject.js +0 -0
  25. package/lib/{routes → v2}/douban/channel/topic.js +0 -0
  26. package/lib/{routes → v2}/douban/commercialpress/latest.js +0 -0
  27. package/lib/{routes → v2}/douban/event/hot.js +0 -0
  28. package/lib/v2/douban/maintainer.js +27 -0
  29. package/lib/{routes/douban → v2/douban/other}/bookstore.js +0 -0
  30. package/lib/{routes/douban → v2/douban/other}/celebrity.js +0 -0
  31. package/lib/{routes/douban → v2/douban/other}/classification.js +0 -0
  32. package/lib/{routes/douban → v2/douban/other}/doulist.js +0 -0
  33. package/lib/v2/douban/other/explore.js +50 -0
  34. package/lib/{routes/douban → v2/douban/other}/explore_column.js +0 -0
  35. package/lib/{routes/douban → v2/douban/other}/group.js +1 -1
  36. package/lib/v2/douban/other/jobs.js +33 -0
  37. package/lib/{routes/douban → v2/douban/other}/later.js +0 -0
  38. package/lib/{routes/douban → v2/douban/other}/latest_book.js +0 -0
  39. package/lib/{routes/douban → v2/douban/other}/latest_music.js +0 -0
  40. package/lib/{routes/douban → v2/douban/other}/playing.js +0 -0
  41. package/lib/{routes/douban → v2/douban/other}/replied.js +0 -0
  42. package/lib/{routes/douban → v2/douban/other}/replies.js +0 -0
  43. package/lib/{routes/douban → v2/douban/other}/topic.js +0 -0
  44. package/lib/{routes/douban → v2/douban/other}/ustop.js +0 -0
  45. package/lib/{routes/douban → v2/douban/other}/weekly_best.js +0 -0
  46. package/lib/{routes → v2}/douban/people/status.js +0 -0
  47. package/lib/{routes → v2}/douban/people/wish.js +0 -0
  48. package/lib/v2/douban/radar.js +54 -0
  49. package/lib/v2/douban/router.js +27 -0
  50. package/lib/v2/douban/templates/explore.art +7 -0
  51. package/lib/v2/epicgames/router.js +1 -1
  52. package/lib/{routes → v2}/github/branches.js +0 -0
  53. package/lib/{routes → v2}/github/contributors.js +0 -0
  54. package/lib/{routes → v2}/github/file.js +0 -0
  55. package/lib/{routes → v2}/github/follower.js +0 -0
  56. package/lib/{routes → v2}/github/issue.js +0 -0
  57. package/lib/v2/github/maintainer.js +12 -0
  58. package/lib/{routes → v2}/github/pulls.js +0 -0
  59. package/lib/v2/github/radar.js +66 -0
  60. package/lib/{routes → v2}/github/repos.js +0 -0
  61. package/lib/v2/github/router.js +12 -0
  62. package/lib/{routes → v2}/github/search.js +0 -0
  63. package/lib/{routes → v2}/github/star.js +0 -0
  64. package/lib/{routes → v2}/github/starred_repos.js +0 -0
  65. package/lib/{routes → v2}/github/topic.js +0 -0
  66. package/lib/{routes → v2}/github/trending.js +3 -3
  67. package/lib/{routes → v2}/google/album.js +0 -0
  68. package/lib/{routes → v2}/google/citations.js +0 -0
  69. package/lib/{routes → v2}/google/doodles.js +0 -0
  70. package/lib/v2/google/fonts.js +43 -0
  71. package/lib/v2/google/maintainer.js +8 -0
  72. package/lib/{routes → v2}/google/news.js +0 -0
  73. package/lib/v2/google/radar.js +64 -0
  74. package/lib/v2/google/router.js +8 -0
  75. package/lib/{routes → v2}/google/scholar.js +0 -0
  76. package/lib/{routes → v2}/google/sites.js +0 -0
  77. package/lib/v2/google/templates/fonts.art +15 -0
  78. package/lib/v2/jandan/index.js +6 -1
  79. package/lib/v2/latepost/index.js +62 -0
  80. package/lib/v2/latepost/maintainer.js +3 -0
  81. package/lib/v2/latepost/radar.js +13 -0
  82. package/lib/v2/latepost/router.js +3 -0
  83. package/lib/v2/leiphone/index.js +1 -1
  84. package/lib/v2/leiphone/radar.js +1 -1
  85. package/lib/v2/leiphone/router.js +1 -1
  86. package/lib/v2/qq/ac/comic.js +43 -0
  87. package/lib/v2/qq/ac/rank.js +20 -0
  88. package/lib/v2/qq/ac/templates/description.art +9 -0
  89. package/lib/v2/qq/ac/utils.js +71 -0
  90. package/lib/v2/qq/maintainer.js +2 -0
  91. package/lib/v2/qq/radar.js +14 -0
  92. package/lib/v2/qq/router.js +2 -0
  93. package/lib/v2/taobao/maintainer.js +3 -0
  94. package/lib/v2/taobao/radar.js +117 -0
  95. package/lib/v2/taobao/router.js +3 -0
  96. package/lib/v2/taobao/templates/zhongchou.art +4 -0
  97. package/lib/{routes → v2}/taobao/zhongchou.js +6 -7
  98. package/lib/v2/wechat/feeddd.js +13 -5
  99. package/lib/v2/wechat/maintainer.js +1 -1
  100. package/package.json +1 -1
  101. package/lib/routes/douban/explore.js +0 -33
  102. package/lib/routes/latepost/index.js +0 -84
package/lib/config.js CHANGED
@@ -211,6 +211,9 @@ const calculateValue = () => {
211
211
  wenku8: {
212
212
  cookie: envs.WENKU8_COOKIE,
213
213
  },
214
+ google: {
215
+ fontsApiKey: envs.GOOGLE_FONTS_API_KEY,
216
+ },
214
217
  };
215
218
  };
216
219
  calculateValue();
@@ -208,7 +208,9 @@ module.exports = async (ctx, next) => {
208
208
  mercury_parser = mercury_parser || require('@postlight/mercury-parser');
209
209
 
210
210
  const res = await got(link);
211
- const $ = cheerio.load(res.data);
211
+ const $ = cheerio.load(res.data, {
212
+ xmlMode: true,
213
+ });
212
214
  const result = await mercury_parser.parse(link, {
213
215
  html: $.html(),
214
216
  });
@@ -243,77 +243,6 @@ module.exports = {
243
243
  },
244
244
  ],
245
245
  },
246
- 'github.com': {
247
- _name: 'GitHub',
248
- '.': [
249
- {
250
- title: '用户仓库',
251
- docs: 'https://docs.rsshub.app/programming.html#github',
252
- source: '/:user',
253
- target: '/github/repos/:user',
254
- },
255
- {
256
- title: '用户 Followers',
257
- docs: 'https://docs.rsshub.app/programming.html#github',
258
- source: '/:user',
259
- target: '/github/user/followers/:user',
260
- },
261
- {
262
- title: 'Trending',
263
- docs: 'https://docs.rsshub.app/programming.html#github',
264
- source: '/trending',
265
- target: '/github/trending/:since',
266
- },
267
- {
268
- title: 'Trending',
269
- docs: 'https://docs.rsshub.app/programming.html#github',
270
- source: '/topics',
271
- target: '/github/topics/:name/:qs?',
272
- },
273
- {
274
- title: '仓库 Issue',
275
- docs: 'https://docs.rsshub.app/programming.html#github',
276
- source: ['/:user/:repo/issues', '/:user/:repo/issues/:id', '/:user/:repo'],
277
- target: '/github/issue/:user/:repo',
278
- },
279
- {
280
- title: '仓库 Pull Requests',
281
- docs: 'https://docs.rsshub.app/programming.html#github',
282
- source: ['/:user/:repo/pulls', '/:user/:repo/pulls/:id', '/:user/:repo'],
283
- target: '/github/pull/:user/:repo',
284
- },
285
- {
286
- title: '仓库 Stars',
287
- docs: 'https://docs.rsshub.app/programming.html#github',
288
- source: ['/:user/:repo/stargazers', '/:user/:repo'],
289
- target: '/github/stars/:user/:repo',
290
- },
291
- {
292
- title: '仓库 Branches',
293
- docs: 'https://docs.rsshub.app/programming.html#github',
294
- source: ['/:user/:repo/branches', '/:user/:repo'],
295
- target: '/github/branches/:user/:repo',
296
- },
297
- {
298
- title: '文件 Commits',
299
- docs: 'https://docs.rsshub.app/programming.html#github',
300
- source: '/:user/:repo/blob/:branch/*filepath',
301
- target: '/github/file/:user/:repo/:branch/:filepath',
302
- },
303
- {
304
- title: '用户 Starred Repositories',
305
- docs: 'https://docs.rsshub.app/programming.html#github',
306
- source: '/:user',
307
- target: '/github/starred_repos/:user',
308
- },
309
- {
310
- title: '仓库 Contributors',
311
- docs: 'https://docs.rsshub.app/programming.html#github',
312
- source: ['/:user/:repo/graphs/contributors', '/:user/:repo'],
313
- target: '/github/contributors/:user/:repo',
314
- },
315
- ],
316
- },
317
246
  'zhihu.com': {
318
247
  _name: '知乎',
319
248
  www: [
@@ -786,17 +715,6 @@ module.exports = {
786
715
  },
787
716
  ],
788
717
  },
789
- 'docker.com': {
790
- _name: 'Docker',
791
- hub: [
792
- {
793
- title: '镜像有新 Build',
794
- docs: 'https://docs.rsshub.app/program-update.html#docker-hub',
795
- source: ['/r/:owner/:image', '/r/:owner/:image/tags', '/_/:image'],
796
- target: (params) => `/dockerhub/build/${params.owner ? params.owner : 'library'}/${params.image}`,
797
- },
798
- ],
799
- },
800
718
  'nga.cn': {
801
719
  _name: 'NGA',
802
720
  bbs: [
@@ -1386,36 +1304,6 @@ module.exports = {
1386
1304
  },
1387
1305
  ],
1388
1306
  },
1389
- 'google.com': {
1390
- _name: '谷歌',
1391
- chrome: [
1392
- {
1393
- title: '插件更新',
1394
- source: '/webstore/detail/:name/:id',
1395
- docs: 'https://docs.rsshub.app/program-update.html#chrome-wang-shang-ying-yong-dian',
1396
- target: '/chrome/webstore/extensions/:id',
1397
- },
1398
- ],
1399
- photos: [
1400
- {
1401
- title: '相册',
1402
- docs: 'https://docs.rsshub.app/picture.html#google-xiang-ce',
1403
- source: '/share/*',
1404
- target: (params, url, document) => {
1405
- const id = document && document.querySelector('html').innerHTML.match(/photos.app.goo.gl\/(.*?)"/)[1];
1406
- return id ? `/google/album/${id}` : '';
1407
- },
1408
- },
1409
- ],
1410
- sites: [
1411
- {
1412
- title: 'Sites',
1413
- docs: 'https://docs.rsshub.app/blog.html#google-sites',
1414
- source: ['/site/:id/*', '/site/:id'],
1415
- target: '/google/sites/:id',
1416
- },
1417
- ],
1418
- },
1419
1307
  'javlibrary.com': {
1420
1308
  _name: 'javlibrary',
1421
1309
  www: [
@@ -2416,38 +2304,6 @@ module.exports = {
2416
2304
  },
2417
2305
  ],
2418
2306
  },
2419
- 'douban.com': {
2420
- _name: '豆瓣',
2421
- www: [
2422
- {
2423
- title: '用户的广播',
2424
- docs: 'https://docs.rsshub.app/social-media.html#dou-ban',
2425
- source: '/people/:user/',
2426
- target: (params, url, document) => {
2427
- const uid = document && document.querySelector('html').innerHTML.match(/"id":"([0-9]+)"/)[1];
2428
- return uid ? `/douban/people/${uid}/status` : '';
2429
- },
2430
- },
2431
- {
2432
- title: '小组-最新',
2433
- docs: 'https://docs.rsshub.app/social-media.html#dou-ban',
2434
- source: '/group/:groupid',
2435
- target: '/douban/group/:groupid',
2436
- },
2437
- {
2438
- title: '小组-最热',
2439
- docs: 'https://docs.rsshub.app/social-media.html#dou-ban',
2440
- source: '/group/:groupid',
2441
- target: '/douban/group/:groupid/essence',
2442
- },
2443
- {
2444
- title: '小组-精华',
2445
- docs: 'https://docs.rsshub.app/social-media.html#dou-ban',
2446
- source: '/group/:groupid',
2447
- target: '/douban/group/:groupid/elite',
2448
- },
2449
- ],
2450
- },
2451
2307
  'okjike.com': {
2452
2308
  _name: '即刻',
2453
2309
  m: [
package/lib/router.js CHANGED
@@ -128,7 +128,7 @@ router.get('/jianshu/collection/:id', lazyloadRouteHandler('./routes/jianshu/col
128
128
  router.get('/jianshu/user/:id', lazyloadRouteHandler('./routes/jianshu/user'));
129
129
 
130
130
  // 知乎
131
- router.get('/zhihu/collection/:id', lazyloadRouteHandler('./routes/zhihu/collection'));
131
+ router.get('/zhihu/collection/:id/:getAll?', lazyloadRouteHandler('./routes/zhihu/collection'));
132
132
  router.get('/zhihu/people/activities/:id', lazyloadRouteHandler('./routes/zhihu/activities'));
133
133
  router.get('/zhihu/people/answers/:id', lazyloadRouteHandler('./routes/zhihu/answers'));
134
134
  router.get('/zhihu/posts/:usertype/:id', lazyloadRouteHandler('./routes/zhihu/posts'));
@@ -163,33 +163,6 @@ router.get('/pixiv/search/:keyword/:order?/:mode?', lazyloadRouteHandler('./rout
163
163
  // pixiv-fanbox
164
164
  router.get('/fanbox/:user?', lazyloadRouteHandler('./routes/fanbox/main'));
165
165
 
166
- // 豆瓣
167
- router.get('/douban/movie/playing', lazyloadRouteHandler('./routes/douban/playing'));
168
- router.get('/douban/movie/playing/:score', lazyloadRouteHandler('./routes/douban/playing'));
169
- router.get('/douban/movie/playing/:score/:city', lazyloadRouteHandler('./routes/douban/playing'));
170
- router.get('/douban/movie/later', lazyloadRouteHandler('./routes/douban/later'));
171
- router.get('/douban/movie/ustop', lazyloadRouteHandler('./routes/douban/ustop'));
172
- router.get('/douban/movie/weekly/:type?', lazyloadRouteHandler('./routes/douban/weekly_best'));
173
- router.get('/douban/movie/classification/:sort?/:score?/:tags?', lazyloadRouteHandler('./routes/douban/classification.js'));
174
- router.get('/douban/group/:groupid/:type?', lazyloadRouteHandler('./routes/douban/group'));
175
- router.get('/douban/explore', lazyloadRouteHandler('./routes/douban/explore'));
176
- router.get('/douban/music/latest/:area?', lazyloadRouteHandler('./routes/douban/latest_music'));
177
- router.get('/douban/book/latest', lazyloadRouteHandler('./routes/douban/latest_book'));
178
- router.get('/douban/event/hot/:locationId', lazyloadRouteHandler('./routes/douban/event/hot'));
179
- router.get('/douban/commercialpress/latest', lazyloadRouteHandler('./routes/douban/commercialpress/latest'));
180
- router.get('/douban/bookstore', lazyloadRouteHandler('./routes/douban/bookstore'));
181
- router.get('/douban/book/rank/:type?', lazyloadRouteHandler('./routes/douban/book/rank'));
182
- router.get('/douban/doulist/:id', lazyloadRouteHandler('./routes/douban/doulist'));
183
- router.get('/douban/explore/column/:id', lazyloadRouteHandler('./routes/douban/explore_column'));
184
- router.get('/douban/people/:userid/status/:routeParams?', lazyloadRouteHandler('./routes/douban/people/status.js'));
185
- router.get('/douban/people/:userid/wish/:routeParams?', lazyloadRouteHandler('./routes/douban/people/wish.js'));
186
- router.get('/douban/replies/:uid', lazyloadRouteHandler('./routes/douban/replies'));
187
- router.get('/douban/replied/:uid', lazyloadRouteHandler('./routes/douban/replied'));
188
- router.get('/douban/topic/:id/:sort?', lazyloadRouteHandler('./routes/douban/topic.js'));
189
- router.get('/douban/channel/:id/:nav?', lazyloadRouteHandler('./routes/douban/channel/topic.js'));
190
- router.get('/douban/channel/:id/subject/:nav', lazyloadRouteHandler('./routes/douban/channel/subject.js'));
191
- router.get('/douban/celebrity/:id/:sort?', lazyloadRouteHandler('./routes/douban/celebrity.js'));
192
-
193
166
  // 法律白話文運動
194
167
  router.get('/plainlaw/archives', lazyloadRouteHandler('./routes/plainlaw/archives.js'));
195
168
 
@@ -272,20 +245,6 @@ router.get('/v2ex/tab/:tabid', lazyloadRouteHandler('./routes/v2ex/tab'));
272
245
  // readhub
273
246
  router.get('/readhub/category/:category', lazyloadRouteHandler('./routes/readhub/category'));
274
247
 
275
- // GitHub
276
- router.get('/github/repos/:user', lazyloadRouteHandler('./routes/github/repos'));
277
- router.get('/github/trending/:since/:language?/:spoken_language?', lazyloadRouteHandler('./routes/github/trending'));
278
- router.get('/github/issue/:user/:repo/:state?/:labels?', lazyloadRouteHandler('./routes/github/issue'));
279
- router.get('/github/pull/:user/:repo', lazyloadRouteHandler('./routes/github/pulls'));
280
- router.get('/github/user/followers/:user', lazyloadRouteHandler('./routes/github/follower'));
281
- router.get('/github/stars/:user/:repo', lazyloadRouteHandler('./routes/github/star'));
282
- router.get('/github/search/:query/:sort?/:order?', lazyloadRouteHandler('./routes/github/search'));
283
- router.get('/github/branches/:user/:repo', lazyloadRouteHandler('./routes/github/branches'));
284
- router.get('/github/file/:user/:repo/:branch/:filepath+', lazyloadRouteHandler('./routes/github/file'));
285
- router.get('/github/starred_repos/:user', lazyloadRouteHandler('./routes/github/starred_repos'));
286
- router.get('/github/contributors/:user/:repo/:order?/:anon?', lazyloadRouteHandler('./routes/github/contributors'));
287
- router.get('/github/topics/:name/:qs?', lazyloadRouteHandler('./routes/github/topic'));
288
-
289
248
  // f-droid
290
249
  router.get('/fdroid/apprelease/:app', lazyloadRouteHandler('./routes/fdroid/apprelease'));
291
250
 
@@ -525,13 +484,6 @@ router.get('/fir/update/:id', lazyloadRouteHandler('./routes/fir/update'));
525
484
  // Nvidia Web Driver
526
485
  router.get('/nvidia/webdriverupdate', lazyloadRouteHandler('./routes/nvidia/webdriverupdate'));
527
486
 
528
- // Google
529
- router.get('/google/citations/:id', lazyloadRouteHandler('./routes/google/citations'));
530
- router.get('/google/scholar/:query', lazyloadRouteHandler('./routes/google/scholar'));
531
- router.get('/google/doodles/:language?', lazyloadRouteHandler('./routes/google/doodles'));
532
- router.get('/google/album/:id', lazyloadRouteHandler('./routes/google/album'));
533
- router.get('/google/sites/:id', lazyloadRouteHandler('./routes/google/sites'));
534
-
535
487
  // 每日环球展览 iMuseum
536
488
  router.get('/imuseum/:city/:type?', lazyloadRouteHandler('./routes/imuseum'));
537
489
 
@@ -1274,9 +1226,6 @@ router.get('/patchwork.kernel.org/comments/:id', lazyloadRouteHandler('./routes/
1274
1226
  // 京东众筹
1275
1227
  router.get('/jingdong/zhongchou/:type/:status/:sort', lazyloadRouteHandler('./routes/jingdong/zhongchou'));
1276
1228
 
1277
- // 淘宝众筹
1278
- router.get('/taobao/zhongchou/:type?', lazyloadRouteHandler('./routes/taobao/zhongchou'));
1279
-
1280
1229
  // All Poetry
1281
1230
  router.get('/allpoetry/:order?', lazyloadRouteHandler('./routes/allpoetry/order'));
1282
1231
 
@@ -1406,9 +1355,6 @@ router.get('/meipai/user/:uid', lazyloadRouteHandler('./routes/meipai/user'));
1406
1355
  // 多知网
1407
1356
  router.get('/duozhi', lazyloadRouteHandler('./routes/duozhi'));
1408
1357
 
1409
- // Docker Hub
1410
- router.get('/dockerhub/build/:owner/:image/:tag?', lazyloadRouteHandler('./routes/dockerhub/build'));
1411
-
1412
1358
  // 人人都是产品经理
1413
1359
  router.get('/woshipm/popular', lazyloadRouteHandler('./routes/woshipm/popular'));
1414
1360
  router.get('/woshipm/wen', lazyloadRouteHandler('./routes/woshipm/wen'));
@@ -3693,7 +3639,7 @@ router.get('/yinxiang/personal/:id', lazyloadRouteHandler('./routes/yinxiang/per
3693
3639
  router.get('/yinxiang/category/:id', lazyloadRouteHandler('./routes/yinxiang/category'));
3694
3640
 
3695
3641
  // 晚点LatePost
3696
- router.get('/latepost/:proma?', lazyloadRouteHandler('./routes/latepost/index'));
3642
+ // router.get('/latepost/:proma?', lazyloadRouteHandler('./routes/latepost/index'));
3697
3643
 
3698
3644
  // 西瓜视频
3699
3645
  router.get('/ixigua/user/video/:uid/:disableEmbed?', lazyloadRouteHandler('./routes/ixigua/userVideo'));
@@ -82,7 +82,6 @@ function getBittorrent(cache, bittorrent_page_url) {
82
82
  if (match_p) {
83
83
  p = match_p[1];
84
84
  }
85
- break;
86
85
  }
87
86
  }
88
87
  }
@@ -1,102 +1,100 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
- const url = require('url');
4
- const iconv = require('iconv-lite');
3
+ const { parseDate } = require('@/utils/parse-date');
5
4
 
6
- const urlRoot = 'http://www.jwc.sjtu.edu.cn/web/sjtu/';
7
-
8
- const transcode = (buffer) => {
9
- const data = iconv.decode(buffer, 'gb2312');
10
- return cheerio.load(data);
11
- };
5
+ const urlRoot = 'https://jwc.sjtu.edu.cn/xwtg';
12
6
 
13
7
  async function getFullArticle(link) {
14
- try {
15
- const response = await got({
16
- method: 'get',
17
- url: link,
18
- responseType: 'buffer',
19
- });
20
- const fullArtData = transcode(response.data);
21
- const fullArt = fullArtData('.main_r_co_fo').html();
22
- return fullArt;
23
- } catch (error) {
24
- return '<h1> 这条消息被 -1s 了 </h1>';
8
+ const response = await got(link);
9
+ const $ = cheerio.load(response.body);
10
+ const content = $('.content-con');
11
+ if (content.length === 0) {
12
+ return null;
25
13
  }
14
+ // resolve links of <img> and <a>
15
+ content.find('img').each((_, e) => {
16
+ const relativeLink = $(e).attr('src');
17
+ const absLink = new URL(relativeLink, urlRoot).href;
18
+ $(e).attr('src', absLink);
19
+ });
20
+ content.find('a').each((_, e) => {
21
+ const relativeLink = $(e).attr('href');
22
+ const absLink = new URL(relativeLink, urlRoot).href;
23
+ $(e).attr('href', absLink);
24
+ });
25
+ return content.html();
26
26
  }
27
27
 
28
28
  module.exports = async (ctx) => {
29
- const type = ctx.params.type || 'students';
29
+ const type = ctx.params.type ?? 'all';
30
30
  const config = {
31
- students: {
32
- link: '198076.htm',
33
- section: '面向学生的通知',
31
+ all: {
32
+ section: '通知通告',
33
+ link: '/tztg.htm',
34
34
  },
35
35
  news: {
36
- link: '198005.htm',
36
+ link: '/xwzx.htm',
37
37
  section: '新闻中心',
38
38
  },
39
39
  notice: {
40
- link: '198392.htm',
40
+ link: '/tztg.htm',
41
41
  section: '通知通告',
42
42
  },
43
43
  operation: {
44
- link: '198042.htm',
44
+ link: '/jxyx.htm',
45
45
  section: '教学运行',
46
46
  },
47
47
  affairs: {
48
- link: '198043.htm',
48
+ link: '/zcxw.htm',
49
49
  section: '注册学务',
50
50
  },
51
51
  yjb: {
52
- link: '198044.htm',
52
+ link: '/yjb.htm',
53
53
  section: '研究办',
54
54
  },
55
55
  jgb: {
56
- link: '198046.htm',
56
+ link: '/jgb.htm',
57
57
  section: '教改办',
58
58
  },
59
59
  zhb: {
60
- link: '198047.htm',
60
+ link: '/zhb.htm',
61
61
  section: '综合办',
62
62
  },
63
+ language: {
64
+ link: '/yywz.htm',
65
+ section: '语言文字',
66
+ },
63
67
  party: {
64
- link: '198097.htm',
68
+ link: '/ghyzb.htm',
65
69
  section: '工会与支部',
66
70
  },
71
+ ge: {
72
+ link: '/tsjy.htm',
73
+ section: '通识教育',
74
+ },
67
75
  };
68
76
 
69
- const sectionLink = url.resolve(urlRoot, config[type].link);
77
+ const sectionLink = urlRoot + config[type].link;
70
78
 
71
79
  const response = await got({
72
80
  method: 'get',
73
81
  url: sectionLink,
74
- responseType: 'buffer',
75
82
  });
76
83
 
77
- const $ = transcode(response.data);
84
+ const $ = cheerio.load(response.body);
78
85
 
79
86
  const out = await Promise.all(
80
- $('.main_r_xuxian')
81
- .find('tr')
82
- .slice(0, 10)
87
+ $('body > div.list-box > div.container > div > div.ny_right > div > div.ny_right_con > div > ul')
88
+ .find('li')
83
89
  .map(async (i, e) => {
84
- const title = $(e)
85
- .find('a')
86
- .text()
87
- .replace(/[\r\n]/g, ' ');
88
- const relativeLink = $(e).find('a').attr('href');
89
- const link = url.resolve(sectionLink, relativeLink);
90
- const date = new Date(
91
- $(e)
92
- .children('td')
93
- .eq(-1)
94
- .text()
95
- .match(/\d{4}-\d{2}-\d{2}/)[0]
96
- );
97
- const timeZone = 8;
98
- const serverOffset = date.getTimezoneOffset() / 60;
99
- const pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString();
90
+ const info = $(e).find('.wz');
91
+ const relativeLink = info.find('a').attr('href');
92
+ const link = new URL(relativeLink, sectionLink).href;
93
+ const title = info.find('a > h2').text();
94
+ const timeElement = $(e).find('.sj');
95
+ const day = timeElement.find('h2').text();
96
+ const yearAndMonth = timeElement.find('p').text();
97
+ const pubDate = parseDate(`${yearAndMonth}.${day}`, 'YYYY.MM.DD');
100
98
  const description = await ctx.cache.tryGet(link, () => getFullArticle(link));
101
99
  const single = {
102
100
  title,
@@ -5,11 +5,11 @@ const cheerio = require('cheerio');
5
5
  const host = 'https://www.yxdzqb.com';
6
6
 
7
7
  const map = {
8
- new: 'index_r.html',
9
- hot: 'index1.html',
10
- hot_chinese: 'index_1c.html',
11
- low: 'index2.html',
12
- low_chinese: 'index_2c.html',
8
+ new: 'index_discount.html',
9
+ hot: 'index_popular.html',
10
+ hot_chinese: 'index_popular_cn.html',
11
+ low: 'index_low.html',
12
+ low_chinese: 'index_low_cn.html',
13
13
  };
14
14
 
15
15
  module.exports = async (ctx) => {
@@ -5,6 +5,7 @@ const { generateData } = require('./pin/utils');
5
5
 
6
6
  module.exports = async (ctx) => {
7
7
  const id = ctx.params.id;
8
+ const getAll = ctx.params.getAll;
8
9
 
9
10
  const response = await got({
10
11
  method: 'get',
@@ -17,6 +18,29 @@ module.exports = async (ctx) => {
17
18
 
18
19
  const list = response.data.data;
19
20
 
21
+ if (getAll) {
22
+ const totals = response.data.paging.totals;
23
+
24
+ const offsetList = [...new Array(Math.round(totals / 20)).keys()].map((item) => item * 20).slice(1);
25
+ const otherList = await Promise.all(
26
+ offsetList.map((offset) =>
27
+ ctx.cache.tryGet(`https://www.zhihu.com/api/v4/collections/${id}/items?offset=${offset}&limit=20`, async () => {
28
+ const response = await got({
29
+ method: 'get',
30
+ url: `https://www.zhihu.com/api/v4/collections/${id}/items?offset=${offset}&limit=20`,
31
+ headers: {
32
+ ...utils.header,
33
+ Referer: `https://www.zhihu.com/collection/${id}`,
34
+ },
35
+ });
36
+
37
+ return response.data.data;
38
+ })
39
+ )
40
+ ).then((item) => item.flat());
41
+ list.push(...otherList);
42
+ }
43
+
20
44
  const response2 = await got({
21
45
  method: 'get',
22
46
  url: `https://www.zhihu.com/collection/${id}`,
@@ -42,9 +66,9 @@ module.exports = async (ctx) => {
42
66
  item.content.type === 'pin'
43
67
  ? generateDataPin(item)
44
68
  : {
45
- title: item.content.type === 'article' ? item.content.title : item.content.question.title,
69
+ title: item.content.type === 'article' || item.content.type === 'zvideo' ? item.content.title : item.content.question.title,
46
70
  link: item.content.url,
47
- description: item.content.content,
71
+ description: item.content.type === 'zvideo' ? `<img src=${item.content.video.url}/>` : item.content.content,
48
72
  pubDate: new Date((item.content.type === 'article' ? item.content.updated : item.content.updated_time) * 1000).toUTCString(),
49
73
  }
50
74
  ),
@@ -17,13 +17,23 @@ module.exports = {
17
17
  break;
18
18
 
19
19
  case 'video':
20
- description += `<video
21
- controls="controls"
22
- width="${item.playlist.hd.width}"
23
- height="${item.playlist.hd.height}"
24
- poster="${item.cover_info.thumbnail}"
25
- src="${item.playlist.hd.play_url}"
26
- >`;
20
+ try {
21
+ description += `<video
22
+ controls="controls"
23
+ width="${item.playlist.hd.width}"
24
+ height="${item.playlist.hd.height}"
25
+ poster="${item.cover_info.thumbnail}"
26
+ src="${item.playlist.hd.play_url}"
27
+ >`;
28
+ } catch (e) {
29
+ description += `<video
30
+ controls="controls"
31
+ width="${item.playlist.pop().width}"
32
+ height="${item.playlist.pop().height}"
33
+ poster="${item.thumbnail}"
34
+ src="${item.playlist.pop().play_url}"
35
+ >`;
36
+ }
27
37
  break;
28
38
 
29
39
  case 'link':
@@ -1,6 +1,7 @@
1
1
  const got = require('@/utils/got');
2
2
  const utils = require('./utils');
3
3
  const cheerio = require('cheerio');
4
+ const { parseDate } = require('@/utils/parse-date');
4
5
 
5
6
  module.exports = async (ctx) => {
6
7
  const id = ctx.params.id;
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
38
39
  title: String(item.title),
39
40
  description: item.content,
40
41
  link: item.url,
41
- pubDate: new Date(item.updated).toUTCString(),
42
+ pubDate: parseDate(item.updated * 1000),
42
43
  })),
43
44
  };
44
45
  };
@@ -1,5 +1,6 @@
1
1
  const got = require('@/utils/got');
2
2
  const utils = require('./utils');
3
+ const { parseDate } = require('@/utils/parse-date');
3
4
 
4
5
  module.exports = async (ctx) => {
5
6
  const { topicId } = ctx.params;
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
32
33
  title = `${item.question.title}-${item.author.name}的回答:${item.excerpt}`;
33
34
  description = `<strong>${item.question.title}</strong><br>${item.author.name}的回答<br/>${utils.ProcessImage(item.content)}`;
34
35
  link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
35
- pubDate = new Date(item.updated_time * 1000).toUTCString();
36
+ pubDate = parseDate(item.updated_time * 1000);
36
37
  author = item.author.name;
37
38
  break;
38
39
 
@@ -40,7 +41,14 @@ module.exports = async (ctx) => {
40
41
  title = item.title;
41
42
  description = item.title;
42
43
  link = `https://www.zhihu.com/question/${item.id}`;
43
- pubDate = new Date(item.created * 1000).toUTCString();
44
+ pubDate = parseDate(item.created * 1000);
45
+ break;
46
+
47
+ case 'article':
48
+ title = item.title;
49
+ description = item.content;
50
+ link = item.url;
51
+ pubDate = parseDate(item.created * 1000);
44
52
  break;
45
53
 
46
54
  default:
@@ -14,6 +14,17 @@ module.exports = async (ctx) => {
14
14
  },
15
15
  });
16
16
 
17
+ const pinnedRes = await got({
18
+ method: 'get',
19
+ url: `https://www.zhihu.com/api/v4/columns/${id}/pinned-items`,
20
+ headers: {
21
+ ...utils.header,
22
+ Referer: `https://zhuanlan.zhihu.com/${id}`,
23
+ },
24
+ });
25
+
26
+ listRes.data.data = listRes.data.data.concat(pinnedRes.data.data);
27
+
17
28
  // 知乎专栏链接存在两种格式, 一种以 'zhuanlan.' 开头, 另一种新增的以 'c_' 结尾
18
29
  let url = `https://zhuanlan.zhihu.com/${id}`;
19
30
  if (id.search('c_') === 0) {
@@ -41,7 +52,7 @@ module.exports = async (ctx) => {
41
52
 
42
53
  if (item.type === 'answer') {
43
54
  title = item.question.title;
44
- author = item.question.author.name;
55
+ author = item.question.author ? item.question.author.name : '';
45
56
  link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
46
57
  pubDate = new Date(item.created_time * 1000);
47
58
  } else if (item.type === 'article') {