From 8a81b00d9d5838cf7fa812918227deb42f90f713 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:04:47 +0800 Subject: [PATCH 1/2] chore(deps-dev): bump lint-staged from 15.2.11 to 15.3.0 (#18007) Bumps [lint-staged](https://github.com/lint-staged/lint-staged) from 15.2.11 to 15.3.0. - [Release notes](https://github.com/lint-staged/lint-staged/releases) - [Changelog](https://github.com/lint-staged/lint-staged/blob/master/CHANGELOG.md) - [Commits](https://github.com/lint-staged/lint-staged/compare/v15.2.11...v15.3.0) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 1d379eec30b678..05450f84fd3909 100644 --- a/package.json +++ b/package.json @@ -184,7 +184,7 @@ "got": "14.4.5", "husky": "9.1.7", "js-beautify": "1.15.1", - "lint-staged": "15.2.11", + "lint-staged": "15.3.0", "mockdate": "3.0.5", "msw": "2.4.3", "node-network-devtools": "1.0.24", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 019a66dfed409f..55acdb980b529d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -413,8 +413,8 @@ importers: specifier: 1.15.1 version: 1.15.1 lint-staged: - specifier: 15.2.11 - version: 15.2.11 + specifier: 15.3.0 + version: 15.3.0 mockdate: specifier: 3.0.5 version: 3.0.5 @@ -2402,6 +2402,10 @@ packages: resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + chalk@5.4.1: + resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + chance@1.1.12: resolution: {integrity: sha512-vVBIGQVnwtUG+SYe0ge+3MvF78cvSpuCOEUJr7sVEk2vSBuMW6OXNJjSzdtzrlxNUEaoqH2GBd5Y/+18BEB01Q==} @@ -3869,8 +3873,8 @@ packages: linkify-it@5.0.0: resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} - lint-staged@15.2.11: - resolution: {integrity: sha512-Ev6ivCTYRTGs9ychvpVw35m/bcNDuBN+mnTeObCL5h+boS5WzBEC6LHI4I9F/++sZm1m+J2LEiy0gxL/R9TBqQ==} + lint-staged@15.3.0: + resolution: {integrity: sha512-vHFahytLoF2enJklgtOtCtIjZrKD/LoxlaUusd5nh7dWv/dkKQJY74ndFSzxCdv7g0ueGg1ORgTSt4Y9LPZn9A==} engines: {node: '>=18.12.0'} hasBin: true @@ -7861,6 +7865,8 @@ snapshots: chalk@5.3.0: {} + chalk@5.4.1: {} + chance@1.1.12: {} character-entities@2.0.2: {} @@ -9538,9 +9544,9 @@ snapshots: dependencies: uc.micro: 2.1.0 - lint-staged@15.2.11: + lint-staged@15.3.0: dependencies: - chalk: 5.3.0 + chalk: 5.4.1 commander: 12.1.0 debug: 4.4.0 execa: 8.0.1 @@ -10095,7 +10101,7 @@ snapshots: openapi3-ts@4.4.0: dependencies: - yaml: 2.6.0 + yaml: 2.6.1 optionator@0.8.3: dependencies: From f5698016d387a0c9902970f6a245395d8ffc0c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=86=E4=B8=BA=E5=90=9B=E6=95=85?= Date: Tue, 31 Dec 2024 02:54:26 +0800 Subject: [PATCH 2/2] feat: add NWMU router. (#17996) * Update package.json * Update package.json * feat: add RSS subscription for (NWMU) Northwestern Minzu University. * fix: fix array generation forms for dom-parser. * fix: fix url replacing behavior. * fix: fix cover images, typos and maintainer. * fix: remove router from deprecated routers. * fix: fix router name and example. * fix: fix items limit. * fix: fix date parser. * fix: use cache for the RSS data. * fix: typo --------- Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> --- lib/routes/xbmu/academic.ts | 91 +++++++++++++++++++++++++++++++++ lib/routes/xbmu/announcement.ts | 91 +++++++++++++++++++++++++++++++++ lib/routes/xbmu/namespace.ts | 6 +++ 3 files changed, 188 insertions(+) create mode 100644 lib/routes/xbmu/academic.ts create mode 100644 lib/routes/xbmu/announcement.ts create mode 100644 lib/routes/xbmu/namespace.ts diff --git a/lib/routes/xbmu/academic.ts b/lib/routes/xbmu/academic.ts new file mode 100644 index 00000000000000..adc99f71b0aef4 --- /dev/null +++ b/lib/routes/xbmu/academic.ts @@ -0,0 +1,91 @@ +import { DataItem, Route } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import { load } from 'cheerio'; + +const BASE_URL = 'https://www.xbmu.edu.cn/xwzx/xsxx.htm'; + +const handler: Route['handler'] = async () => { + try { + // Fetch the academic page + const { data: listResponse } = await got(BASE_URL); + const $ = load(listResponse); + + // Select all list items containing academic information + const ITEM_SELECTOR = 'body > div.container.list-container.ny_mani > div > div.news_list > ul > li'; + const listItems = $(ITEM_SELECTOR); + + // Map through each list item to extract details + const academicLinkList = await Promise.all( + listItems.toArray().map((element) => { + const rawDate = $(element).find('span').text().trim(); + const [day, yearMonth] = rawDate.split('/').map((s) => s.trim()); + const formattedDate = parseDate(`${yearMonth}-${day}`).toUTCString(); + + const title = $(element).find('a').attr('title') || '学术信息'; + const relativeHref = $(element).find('a').attr('href') || ''; + const link = `https://www.xbmu.edu.cn/${relativeHref.replaceAll('../', '')}`; + + return { + date: formattedDate, + title, + link, + }; + }) + ); + + return { + title: '西北民族大学学术信息', + description: '西北民族大学近日学术信息', + link: BASE_URL, + image: 'http://210.26.0.114:9090/mdxg/img/weex/default_img.jpg', + item: (await Promise.all( + academicLinkList.map((item) => + cache.tryGet(item.link, async () => { + const CONTENT_SELECTOR = '#vsb_content > div'; + const { data: contentResponse } = await got(item.link); + const contentPage = load(contentResponse); + const content = contentPage(CONTENT_SELECTOR).html() || ''; + return { + title: item.title, + pubDate: item.date, + link: item.link, + description: content, + category: ['university'], + guid: item.link, + id: item.link, + image: 'http://210.26.0.114:9090/mdxg/img/weex/default_img.jpg', + content, + updated: item.date, + language: 'zh-cn', + }; + }) + ) + )) as DataItem[], + allowEmpty: true, + language: 'zh-cn', + feedLink: 'https://rsshub.app/xbmu/academic', + id: 'https://rsshub.app/xbmu/academic', + }; + } catch (error) { + throw new Error(`Error fetching academic information: ${error}`); + } +}; + +export const route: Route = { + path: '/academic', + name: '学术信息', + maintainers: ['PrinOrange'], + handler, + categories: ['university'], + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + example: '/xbmu/academic', +}; diff --git a/lib/routes/xbmu/announcement.ts b/lib/routes/xbmu/announcement.ts new file mode 100644 index 00000000000000..56d4486c0a701f --- /dev/null +++ b/lib/routes/xbmu/announcement.ts @@ -0,0 +1,91 @@ +import { DataItem, Route } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import { load } from 'cheerio'; + +const BASE_URL = 'https://www.xbmu.edu.cn/xwzx/tzgg.htm'; + +const handler: Route['handler'] = async () => { + try { + // Fetch the announcements page + const { data: listResponse } = await got(BASE_URL); + const $ = load(listResponse); + + // Select all list items containing announcement information + const ITEM_SELECTOR = 'body > div.container.list-container.ny_mani > div > div.news_list > ul > li'; + const listItems = $(ITEM_SELECTOR); + + // Map through each list item to extract details + const announcementLinkList = await Promise.all( + listItems.toArray().map((element) => { + const rawDate = $(element).find('span').text().trim(); + const [day, yearMonth] = rawDate.split('/').map((s) => s.trim()); + const formattedDate = parseDate(`${yearMonth}-${day}`).toUTCString(); + + const title = $(element).find('a').attr('title') || '通知公告'; + const relativeHref = $(element).find('a').attr('href') || ''; + const link = `https://www.xbmu.edu.cn/${relativeHref.replaceAll('../', '')}`; + + return { + date: formattedDate, + title, + link, + }; + }) + ); + + return { + title: '西北民族大学通知公告', + description: '西北民族大学近日通知公告', + link: BASE_URL, + image: 'http://210.26.0.114:9090/mdxg/img/weex/default_img.jpg', + item: (await Promise.all( + announcementLinkList.map((item) => + cache.tryGet(item.link, async () => { + const CONTENT_SELECTOR = '#vsb_content > div'; + const { data: contentResponse } = await got(item.link); + const contentPage = load(contentResponse); + const content = contentPage(CONTENT_SELECTOR).html() || ''; + return { + title: item.title, + pubDate: item.date, + link: item.link, + description: content, + category: ['university'], + guid: item.link, + id: item.link, + image: 'http://210.26.0.114:9090/mdxg/img/weex/default_img.jpg', + content, + updated: item.date, + language: 'zh-cn', + }; + }) + ) + )) as DataItem[], + allowEmpty: true, + language: 'zh-cn', + feedLink: 'https://rsshub.app/xbmu/announcement', + id: 'https://rsshub.app/xbmu/announcement', + }; + } catch (error) { + throw new Error(`Error fetching announcements: ${error}`); + } +}; + +export const route: Route = { + path: '/announcement', + name: '通知公告', + maintainers: ['PrinOrange'], + handler, + categories: ['university'], + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + example: '/xbmu/announcement', +}; diff --git a/lib/routes/xbmu/namespace.ts b/lib/routes/xbmu/namespace.ts new file mode 100644 index 00000000000000..08c824cda68fa0 --- /dev/null +++ b/lib/routes/xbmu/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '西北民族大学', + url: 'www.xbmu.edu.cn', +};